hurl/contrib/windows/powershell_build.md
2021-02-02 18:23:51 +01:00

4.5 KiB

What ?

This document describes the steps to build the windows 64bits hurl binary with powershell.exe.

All command have been launched with admin privileges on c:\ root dir and executed sequentially. (If you don't want to use c:\ as installation path and git clone path, please replace all its references before executing commands )

All the steps have been tested on a blank Windows 10 64bits and total operation time is about 30 minutes with a xdsl connection (5mb/sec).

You just have to follow each chapter sequentially until you get a windows installer allowing the native installation of hurl on your favorite windows 64bits computer.

Win64 workspace installation

Manual softwares installation :

Command line softwares installation

cd c:\
choco install --confirm --no-progress git nsis python3 winlibs-llvm-free nsis
Invoke-WebRequest -UseBasicParsing -OutFile "c:\rustup-init.exe" "https://static.rust-lang.org/rustup/dist/i686-pc-windows-gnu/rustup-init.exe"
c:\rustup-init.exe -y  --default-toolchain stable-x86_64-pc-windows-msvc
Set-ItemProperty -Path HKCU:\Environment -Name RUST_BACKTRACE -Value "full"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") 
git.exe clone https://github.com/microsoft/vcpkg
c:\vcpkg\bootstrap-vcpkg.bat
$oldpath = Get-ItemProperty -Path HKCU:\Environment -Name Path
$newpath = $oldpath.Path += ";c:\vcpkg"
Set-ItemProperty -Path HKCU:\Environment -Name Path -Value $newpath
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") 
vcpkg install libxml2:x64-windows
vcpkg integrate install
Set-ItemProperty -Path HKCU:\Environment -Name VCPKGRS_DYNAMIC -Value "1"
$env:VCPKGRS_DYNAMIC = [System.Environment]::GetEnvironmentVariable("VCPKGRS_DYNAMIC","User")

Clone hurl project

git.exe clone https://github.com/Orange-OpenSource/hurl

Fix currently known win64 hurl compilation bugs

powershell

(Get-Content c:\hurl\packages\hurl\src\runner\hurl_file.rs).replace('```', '') | Set-Content c:\hurl\packages\hurl\src\runner\hurl_file.rs

Build win64 exe binary

cd c:\hurl
cargo build --release --verbose
New-Item -ItemType "Directory" -Path "c:\hurl\target" -Name "win-package"
Get-ChildItem -Path "c:\hurl\target\release" -Recurse -Include *.dll -File | Copy-Item -Destination "c:\hurl\target\win-package"
Get-ChildItem -Path "c:\hurl\target\release" -Recurse -Include hurl*.exe -File | Copy-Item -Destination "c:\hurl\target\win-package"
((c:\hurl\target\win-package\hurl.exe --version) -Split " ")[1] > c:\hurl\target\win-package\version.txt

Test your app

install proxy and server

pip3 install mitmproxy flask

Keep original powershell prompt on background, and open one more separate powershell prompt to launch the server

cd c:\hurl\integration
python server.py

Keep original powershell prompt on background, and open one more separate powershell prompt to launch the proxy

mitmdump --listen-port 8888 --modify-header "/From-Proxy/Hello"

focus on original powershell prompt and launch hurl unit tests

cd c:\hurl\integration
cargo test --verbose

launch hurl integration tests

coming soon ... ;)

Generate version.txt file

((c:\hurl\target\win-package\hurl.exe --version) -Split " ")[1] > c:\hurl\target\win-package\version.txt

Create a simple zip package

$hurl_package_version = Get-Content c:\hurl\target\win-package\version.txt
cd c:\hurl\target\win-package
Get-ChildItem -Path *.dll, *hurl.exe, *.txt | Compress-Archive -DestinationPath hurl_${hurl_package_version}_win64.zip

Create a real package installer for win64

cd c:\hurl\target\win-package
$oldpath = Get-ItemProperty -Path HKCU:\Environment -Name Path
$newpath = $oldpath.Path += ";C:\Program Files (x86)\NSIS\Bin"
Set-ItemProperty -Path HKCU:\Environment -Name Path -Value $newpath
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") 
makensis.exe /NOCD /V4 ..\..\contrib\windows\hurl.nsi