From e94cf1a3d5407c8098c61a00eb59e5d805c45414 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Wed, 31 Jul 2024 23:26:15 +0300 Subject: [PATCH] Add Windows Arm64 build IB-8160 Signed-off-by: Raul Metsma --- .github/workflows/build.yml | 16 +++++++++----- CMakeLists.txt | 2 +- README.md | 20 +++++++++-------- build.ps1 | 43 +++++++++++++++++++++---------------- libdigidocpp.wxs | 9 +++++++- src/CMakeLists.txt | 18 +++++++++------- 6 files changed, 66 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 488356cf2..ba7a27ed1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,14 +145,18 @@ jobs: strategy: matrix: toolset: [143, 142] - platform: [x86, x64] + platform: [x86, x64, arm64] include: - toolset: 143 image: windows-2022 - vcvars: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat" - toolset: 142 image: windows-2019 - vcvars: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat" + - platform: x86 + setenv: amd64_x86 + - platform: x64 + setenv: amd64 + - platform: arm64 + setenv: amd64_arm64 env: VER_SUFFIX: .VS${{ matrix.toolset }} CXXFLAGS: '/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR' # https://github.com/actions/runner-images/issues/10004 @@ -182,12 +186,14 @@ jobs: run: | dotnet tool install -g wix --version 5.0.1 wix extension -g add WixToolset.UI.wixext/5.0.1 + - name: Setup dev env + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.setenv }} - name: Build run: | & .\build.ps1 ` -vcpkg_installed ${{ env.VCPKG_INSTALLED_DIR }} ` - -vcvars "${{ matrix.vcvars }}" ` - -platform ${{ matrix.platform }} ` -swig C:/ProgramData/chocolatey/bin/swig.exe ` -doxygen "C:/Program files/doxygen/bin/doxygen.exe" ` -boost diff --git a/CMakeLists.txt b/CMakeLists.txt index 46ed99fb8..53a7100d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,7 @@ enable_testing() add_subdirectory(src) add_subdirectory(examples) -find_package( Boost COMPONENTS unit_test_framework ) +find_package(Boost COMPONENTS unit_test_framework QUIET) if(TARGET Boost::unit_test_framework) add_subdirectory(test) endif() diff --git a/README.md b/README.md index e6585f10d..98dde3eda 100644 --- a/README.md +++ b/README.md @@ -94,16 +94,18 @@ * [Python](https://www.python.org/downloads/) - Optional, for Python bindings * [Java](https://www.oracle.com/java/technologies/downloads/) - Optional, for Java bindings - Toolset: - * 142 - Visual Studio 2019 (Default) - * 143 - Visual Studio 2022 +2. Open desired Visual Studio tools command prompt: + * x64 Native Tool Command Prompt + * x86 Native Tool Command Prompt + * ARM64 Native Tool Command Prompt + * Or some cross compile combination with target host type -2. Fetch the source +3. Fetch the source git clone --recursive https://github.com/open-eid/libdigidocpp cd libdigidocpp -3. Configure +4. Configure cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake ` -DVCPKG_TARGET_TRIPLET=x64-windows ` @@ -117,18 +119,18 @@ After running the cmake build, digidoc_csharp.dll along with the C# source files will be created, more info at [examples/DigiDocCSharp/README.md](examples/DigiDocCSharp/README.md). -4. Build +5. Build cmake --build build -5. Alternative to steps 4. and 5. - +6. Alternative to steps 4. and 5. - - powershell -ExecutionPolicy ByPass -File build.ps1 -platform x64 + powershell -ExecutionPolicy ByPass -File build.ps1 The build script builds executables and installation media for given platform (Debug and Release with debug symbols) -6. Execute +7. Execute build/src/digidoc-tool.exe diff --git a/build.ps1 b/build.ps1 index 4a0e86c83..16368d2d6 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,19 +1,18 @@ #powershell -ExecutionPolicy ByPass -File build.ps1 param( [string]$libdigidocpp = $PSScriptRoot, + [string]$platform = $env:VSCMD_ARG_TGT_ARCH, + [string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}), + [string]$msiversion = "4.0.0.$build_number", + [string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi", [string]$git = "git.exe", [string]$vcpkg = "vcpkg\vcpkg.exe", [string]$vcpkg_dir = (split-path -parent $vcpkg), [string]$vcpkg_installed = $libdigidocpp, [string]$vcpkg_installed_platform = "$vcpkg_installed\vcpkg_installed_$platform", - [string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}), - [string]$msiversion = "4.0.0.$build_number", - [string]$platform = "x64", - [string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi", + [string]$vcpkg_triplet = "$platform-windows", [string]$cmake = "cmake.exe", [string]$generator = "NMake Makefiles", - [string]$vcvars = "vcvarsall", - [string]$wix = "wix.exe", [string]$swig = $null, [string]$doxygen = $null, [switch]$boost = $false, @@ -21,17 +20,16 @@ param( ) Try { - & $wix > $null + & wix > $null } Catch { & dotnet tool install --global --version 5.0.1 wix - & $wix extension add -g WixToolset.UI.wixext/5.0.1 + & wix extension add -g WixToolset.UI.wixext/5.0.1 } if(!(Test-Path -Path $vcpkg)) { & $git clone https://github.com/microsoft/vcpkg $vcpkg_dir & $vcpkg_dir\bootstrap-vcpkg.bat - & $vcpkg install --clean-after-build --triplet x64-windows --x-feature=tests --x-install-root=$vcpkg_installed_platform } $cmakeext = @() @@ -45,6 +43,13 @@ if($doxygen) { $cmakeext += "-DDOXYGEN_EXECUTABLE=$doxygen" $wixext += "-d", "docLocation=$(Get-Location)/$platform/share/doc/libdigidocpp" } +if($env:VSCMD_ARG_HOST_ARCH -ne "arm64") { + $cmakeext += "-DCMAKE_DISABLE_FIND_PACKAGE_Python3=yes" + $wixext += "-d", "disablePython=1" + if($platform -eq "arm64") { + $boost = $false + } +} if($boost) { $cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests" $target += "check" @@ -52,34 +57,36 @@ if($boost) { foreach($type in @("Debug", "RelWithDebInfo")) { $buildpath = $platform+$type - & $vcvars $platform "&&" $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" ` + & $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" $cmakeext ` "-DCMAKE_BUILD_TYPE=$type" ` "-DCMAKE_INSTALL_PREFIX=$platform" ` "-DCMAKE_INSTALL_LIBDIR=bin" ` "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake" ` "-DVCPKG_INSTALLED_DIR=$vcpkg_installed_platform" ` - "-DSIGNCERT=$sign" ` - $cmakeext "&&" $cmake --build $buildpath --target $target "&&" $cmake --install $buildpath + "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" ` + "-DSIGNCERT=$sign" + & $cmake --build $buildpath --target $target + & $cmake --install $buildpath } if($sign) { - & $vcvars $platform "&&" signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee ` + & signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee ` /tr http://timestamp.digicert.com /td SHA256 ` - $vcpkg_installed_platform/$platform-windows/bin/*.dll ` - $vcpkg_installed_platform/$platform-windows/debug/bin/*.dll + $vcpkg_installed_platform/$vcpkg_triplet/bin/*.dll ` + $vcpkg_installed_platform/$vcpkg_triplet/debug/bin/*.dll } -& $vcvars $platform "&&" $wix build -nologo -arch $platform -out $msi_name $wixext ` +& wix build -nologo -arch $platform -out $msi_name $wixext ` -ext WixToolset.UI.wixext ` -bv "WixUIBannerBmp=$libdigidocpp/cmake/modules/banner.bmp" ` -bv "WixUIDialogBmp=$libdigidocpp/cmake/modules/dlgbmp.bmp" ` -d "ICON=$libdigidocpp/cmake/modules/ID.ico" ` -d "MSI_VERSION=$msiversion" ` - -d "vcpkg=$vcpkg_installed_platform/$platform-windows" ` + -d "vcpkg=$vcpkg_installed_platform/$vcpkg_triplet" ` -d "libdigidocpp=$(Get-Location)/$platform" ` $libdigidocpp\libdigidocpp.wxs if($sign) { - & $vcvars $platform "&&" signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee ` + & signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee ` /tr http://timestamp.digicert.com /td SHA256 "$msi_name" } diff --git a/libdigidocpp.wxs b/libdigidocpp.wxs index 7ee740bdd..f52d66d8f 100644 --- a/libdigidocpp.wxs +++ b/libdigidocpp.wxs @@ -1,12 +1,15 @@  + + + @@ -31,7 +34,7 @@ - + + + @@ -86,7 +91,9 @@ + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 81b15fd88..07e6cfb58 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -236,15 +236,17 @@ if(WIN32) install(FILES $ $ DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL) if(SIGNCERT) foreach(TARGET digidocpp digidoc-tool digidoc_java digidoc_csharp digidoc_python) - if(CROSSSIGNCERT) - target_link_options(${TARGET} PRIVATE "/INTEGRITYCHECK") + if (TARGET ${TARGET}) + if(CROSSSIGNCERT) + target_link_options(${TARGET} PRIVATE "/INTEGRITYCHECK") + endif() + add_custom_command(TARGET ${TARGET} POST_BUILD + COMMAND signtool.exe sign /a /v /s MY /n "${SIGNCERT}" /fd SHA256 /du http://installer.id.ee + "$<$:/ph;/ac;${CROSSSIGNCERT}>" + /tr http://timestamp.digicert.com /td SHA256 $ + COMMAND_EXPAND_LISTS + ) endif() - add_custom_command(TARGET ${TARGET} POST_BUILD - COMMAND signtool.exe sign /a /v /s MY /n "${SIGNCERT}" /fd SHA256 /du http://installer.id.ee - "$<$:/ph;/ac;${CROSSSIGNCERT}>" - /tr http://timestamp.digicert.com /td SHA256 $ - COMMAND_EXPAND_LISTS - ) endforeach() endif() endif()