Merge pull request #138 from Orange-OpenSource/doc/contrib-windows

add windows build documentation
This commit is contained in:
Fabrice Reix 2021-02-02 19:40:47 +01:00 committed by GitHub
commit 956e21453e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 247 additions and 1 deletions

View File

@ -308,6 +308,7 @@ HTTP/* 302
[Doc](https://hurl.dev/docs/capturing-response.html#xpath-capture) [Doc](https://hurl.dev/docs/capturing-response.html#xpath-capture)
# Building # Building
## linux
Hurl is written in [Rust](https://www.rust-lang.org/). Hurl is written in [Rust](https://www.rust-lang.org/).
You should [install](https://www.rust-lang.org/tools/install) the You should [install](https://www.rust-lang.org/tools/install) the
@ -332,7 +333,9 @@ $ ./target/release/hurl --version
cargo install --path packages/hurl cargo install --path packages/hurl
``` ```
## windows64
please follow the [contrib/windows section](contrib/windows/README.md)
# Feedbacks # Feedbacks

11
contrib/windows/README.md Normal file
View File

@ -0,0 +1,11 @@
# What ?
This document describes the steps to build the `windows 64bits hurl binary`.
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.
## choose between your prefered build method
- [using old fashion way with cmd.exe](cmd_build.md)
- [using modern style with powershell.exe](powershell_build.md)

View File

@ -0,0 +1,113 @@
# What ?
This document describes the steps to build the `windows 64bits hurl binary` with `cmd.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 :
- install `builds tools c++` and `english language` by executing https://visualstudio.microsoft.com/fr/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16
- install `choco` by executing https://docs.chocolatey.org/en-us/choco/setup#install-with-cmd.exe
## Command line softwares installation
```cmd
cd c:\
choco install --confirm --no-progress curl unxUtils git 7zip nsis python3 winlibs-llvm-free
refreshenv
%ChocolateyInstall%\bin\curl --output "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
setx RUST_BACKTRACE "full" /M
refreshenv
git.exe clone https://github.com/microsoft/vcpkg
c:\vcpkg\bootstrap-vcpkg.bat
setx /M PATH "%PATH%;c:\vcpkg"
setx VCPKGRS_DYNAMIC "1" /M
refreshenv
vcpkg install libxml2:x64-windows
vcpkg integrate install
```
## Clone hurl project
```cmd
git.exe clone https://github.com/Orange-OpenSource/hurl
```
## Fix currently known win64 hurl compilation bugs
```cmd
cp -frp c:\hurl\packages\hurl\src\runner\hurl_file.rs c:\hurl\packages\hurl\src\runner\hurl_file.rs.ori
%ChocolateyInstall%\bin\sed.exe "s/```//g" c:\hurl\packages\hurl\src\runner\hurl_file.rs.ori > c:\hurl\packages\hurl\src\runner\hurl_file.rs
```
## Build win64 exe binary
```cmd
cd c:\hurl
cargo build --release --verbose
mkdir c:\hurl\target\win-package
%ChocolateyInstall%\bin\find c:\hurl\target\release -name "*.dll" | xargs -i cp -frp {} c:\hurl\target\win-package
%ChocolateyInstall%\bin\find c:\hurl\target\release -maxdepth 1 -name "hurl*.exe" | xargs -i cp -frp {} c:\hurl\target\win-package
setx /M PATH "%PATH%;c:\hurl\target\win-package"
refreshenv
```
## Test your app
launch proxy server
```cmd
pip3 install mitmproxy
start /B mitmdump -p 8888 --modify-header "/From-Proxy/Hello"
```
launch test server
```cmd
pip3 install flask
cd c:\hurl\integration
start /B server.py
```
launch hurl unit tests
```cmd
cd c:\hurl
cargo test
```
launch hurl integration tests
```
coming soon ... ;)
```
## Generate version.txt file
```cmd
hurl.exe --version | cut -d" " -f2 > c:\hurl\target\win-package\version.txt
```
## Create a simple zip package
```cmd
set /P hurl_package_version=<c:\hurl\target\win-package\version.txt
cd c:\hurl\target\win-package
7z.exe a -y hurl_%hurl_package_version%_win64.zip *.dll *hurl.exe *.txt
```
## Create a real package installer for win64
```cmd
setx /M path "%path%;C:\Program Files (x86)\NSIS\Bin"
refreshenv
cd c:\hurl\target\win-package
makensis /NOCD /V4 c:\hurl\contrib\windows\hurl.nsi
```

View File

@ -0,0 +1,119 @@
# 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 :
- install `builds tools c++` and `english language` by executing https://visualstudio.microsoft.com/fr/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16
- install `choco` by executing https://docs.chocolatey.org/en-us/choco/setup#install-with-powershell.exe
## Command line softwares installation
```powershell
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
```powershell
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
```powershell
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
```powershell
pip3 install mitmproxy flask
```
Keep original powershell prompt on background, and open one more separate powershell prompt to launch the server
```powershell
cd c:\hurl\integration
python server.py
```
Keep original powershell prompt on background, and open one more separate powershell prompt to launch the proxy
```powershell
mitmdump --listen-port 8888 --modify-header "/From-Proxy/Hello"
```
focus on original powershell prompt and launch hurl unit tests
```powershell
cd c:\hurl\integration
cargo test --verbose
```
launch hurl integration tests
```powershell
coming soon ... ;)
```
## Generate version.txt file
```powershell
((c:\hurl\target\win-package\hurl.exe --version) -Split " ")[1] > c:\hurl\target\win-package\version.txt
```
## Create a simple zip package
```powershell
$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
```powershell
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
```