Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows Arm64 build #621

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
brew install --formula ninja swig doxygen boost
brew unlink [email protected] || true
brew unlink [email protected] || true
brew unlink [email protected] || true
brew unlink openssl@3 || true
brew unlink xz
- name: Cache
uses: actions/cache@v4
Expand Down Expand Up @@ -129,12 +131,19 @@ jobs:
runs-on: ${{ matrix.image }}
strategy:
matrix:
toolset: [143]
platform: [x86, x64]
toolset: [143, 142]
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
- 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
Expand All @@ -161,11 +170,13 @@ jobs:
with:
python-version: 3.12
architecture: x86
- name: Setup dev env
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.setenv }}
- name: Build
run: |
& .\build.ps1 `
-vcvars "${{ matrix.vcvars }}" `
-platform ${{ matrix.platform }} `
-swig ${{ github.workspace }}/swigwin-4.2.1/swig.exe `
-doxygen "C:/Program files/doxygen/bin/doxygen.exe" `
-boost
Expand Down Expand Up @@ -214,9 +225,12 @@ jobs:
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
- name: Build
run: |
cmake .
cmake -B build -S . \
-DCMAKE_DISABLE_FIND_PACKAGE_SWIG=YES \
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=YES \
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=YES
export PATH=$PWD/cov-analysis-linux64/bin:$PATH
cov-build --dir cov-int cmake --build .
cov-build --dir cov-int cmake --build build
- name: Submit the result to Coverity Scan
run: |
tar czvf upload.tgz cov-int
Expand Down
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

2. Fetch the source

git clone --recursive https://github.com/open-eid/libdigidocpp
git clone https://github.com/open-eid/libdigidocpp
cd libdigidocpp

3. Configure
Expand Down Expand Up @@ -56,7 +56,7 @@

2. Fetch the source

git clone --recursive https://github.com/open-eid/libdigidocpp
git clone https://github.com/open-eid/libdigidocpp
cd libdigidocpp

3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64)
Expand Down Expand Up @@ -88,47 +88,56 @@
* [Visual Studio Community 2019/2022](https://www.visualstudio.com/downloads/)
* [CMake](http://www.cmake.org)
* [vcpkg](https://vcpkg.io/)
* [Swig](http://swig.org/download.html) - Optional, for C# and Java bindings
* [Doxygen](https://www.doxygen.nl/download.html) - Optional, for generationg documentation
* [Swig](http://swig.org/download.html) - Optional, for C#, Python and Java bindings
* [Doxygen](https://www.doxygen.nl/download.html) - Optional, for generating documentation
* [Wix toolset](http://wixtoolset.org/releases/) - Optional, for creating Windows installation packages
* [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
git clone 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 `
-DVCPKG_MANIFEST_FEATURES=tests `
-B build -S .

Optional CMake parameters:
Optional CMake parameters:

-DSWIG_EXECUTABLE=C:/swigwin-4.2.1/swig.exe
-DSWIG_EXECUTABLE=C:/swigwin-4.2.1/swig.exe
-DDOXYGEN_EXECUTABLE=C:/Program files/doxygen/bin/doxygen.exe

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).
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

Optional build.ps1 parameters:

-swig C:/swigwin-4.2.1/swig.exe
-doxygen "C:/Program files/doxygen/bin/doxygen.exe"
-boost

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

Expand Down
37 changes: 23 additions & 14 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#powershell -ExecutionPolicy ByPass -File build.ps1
param(
[string]$libdigidocpp = $PSScriptRoot,
[string]$platform = "x64",
[string]$platform = $env:VSCMD_ARG_TGT_ARCH,
[string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}),
[string]$msiversion = "4.1.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.1.0.$build_number",
[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]$swig = $null,
[string]$doxygen = $null,
[switch]$boost = $false,
Expand Down Expand Up @@ -43,40 +43,49 @@ 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"
}

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/banner.bmp" `
-bv "WixUIDialogBmp=$libdigidocpp/dlgbmp.bmp" `
-d "ICON=$libdigidocpp/ID.ico" `
-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"
}
9 changes: 8 additions & 1 deletion libdigidocpp.wxs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?if $(sys.BUILDARCH) = x64 ?>
<?define UpgradeCode = "{93985BBA-6B59-443B-80C8-BA987407F8B8}" ?>
<?define OpenSSLSuffix = "-x64" ?>
<?define Suffix = "" ?>
<?elseif $(sys.BUILDARCH) = arm64 ?>
<?define UpgradeCode = "{de2f0796-01fe-4291-bfc1-c01f631d082b}" ?>
<?define OpenSSLSuffix = "-arm64" ?>
<?define Suffix = "-arm64" ?>
<?else?>
<?define UpgradeCode = "{7f1b1519-b527-4130-998d-233f4d050f14}" ?>
<?define OpenSSLSuffix = "" ?>
<?define Suffix = "" ?>
<?endif?>

<?if $(env.VisualStudioVersion) = "17.0" ?>
Expand All @@ -31,7 +34,7 @@
</UI>

<StandardDirectory Id="ProgramFiles6432Folder">
<Directory Id="INSTALLFOLDER" Name="libdigidocpp" />
<Directory Id="INSTALLFOLDER" Name="libdigidocpp$(var.Suffix)" />
</StandardDirectory>

<ComponentGroup Id="Runtime"
Expand Down Expand Up @@ -60,8 +63,10 @@
<?ifdef var.swig ?>
<File Name="digidoc_csharp.dll" />
<File Name="digidoc_java.dll" />
<?ifndef var.disablePython ?>
<File Name="_digidoc_python.pyd" />
<File Name="digidoc.py" />
<?endif?>
<?endif?>
</ComponentGroup>

Expand All @@ -86,7 +91,9 @@
<?ifdef var.swig ?>
<File Name="digidoc_csharpd.dll" />
<File Name="digidoc_javad.dll" />
<?ifndef var.disablePython ?>
<File Name="_digidoc_pythond.pyd" />
<?endif?>
<?endif?>
</ComponentGroup>

Expand Down
18 changes: 10 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,17 @@ if(WIN32)
install(FILES $<TARGET_PDB_FILE:digidocpp> $<TARGET_PDB_FILE:digidoc-tool> 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
"$<$<BOOL:${CROSSSIGNCERT}>:/ph;/ac;${CROSSSIGNCERT}>"
/tr http://timestamp.digicert.com /td SHA256 $<TARGET_FILE:${TARGET}>
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
"$<$<BOOL:${CROSSSIGNCERT}>:/ph;/ac;${CROSSSIGNCERT}>"
/tr http://timestamp.digicert.com /td SHA256 $<TARGET_FILE:${TARGET}>
COMMAND_EXPAND_LISTS
)
endforeach()
endif()
endif()
Expand Down
Loading