Skip to content

Commit 046e5a9

Browse files
authored
Add Windows Arm64 build (#621)
IB-8160 Signed-off-by: Raul Metsma <[email protected]>
1 parent aba89db commit 046e5a9

File tree

5 files changed

+89
-48
lines changed

5 files changed

+89
-48
lines changed

.github/workflows/build.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
brew install --formula ninja swig doxygen boost
2525
brew unlink [email protected] || true
2626
brew unlink [email protected] || true
27+
brew unlink [email protected] || true
28+
brew unlink openssl@3 || true
2729
brew unlink xz
2830
- name: Cache
2931
uses: actions/cache@v4
@@ -129,12 +131,19 @@ jobs:
129131
runs-on: ${{ matrix.image }}
130132
strategy:
131133
matrix:
132-
toolset: [143]
133-
platform: [x86, x64]
134+
toolset: [143, 142]
135+
platform: [x86, x64, arm64]
134136
include:
135137
- toolset: 143
136138
image: windows-2022
137-
vcvars: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat"
139+
- toolset: 142
140+
image: windows-2019
141+
- platform: x86
142+
setenv: amd64_x86
143+
- platform: x64
144+
setenv: amd64
145+
- platform: arm64
146+
setenv: amd64_arm64
138147
env:
139148
VER_SUFFIX: .VS${{ matrix.toolset }}
140149
CXXFLAGS: '/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR' # https://github.com/actions/runner-images/issues/10004
@@ -161,11 +170,13 @@ jobs:
161170
with:
162171
python-version: 3.12
163172
architecture: x86
173+
- name: Setup dev env
174+
uses: ilammy/msvc-dev-cmd@v1
175+
with:
176+
arch: ${{ matrix.setenv }}
164177
- name: Build
165178
run: |
166179
& .\build.ps1 `
167-
-vcvars "${{ matrix.vcvars }}" `
168-
-platform ${{ matrix.platform }} `
169180
-swig ${{ github.workspace }}/swigwin-4.2.1/swig.exe `
170181
-doxygen "C:/Program files/doxygen/bin/doxygen.exe" `
171182
-boost
@@ -214,9 +225,12 @@ jobs:
214225
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
215226
- name: Build
216227
run: |
217-
cmake .
228+
cmake -B build -S . \
229+
-DCMAKE_DISABLE_FIND_PACKAGE_SWIG=YES \
230+
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=YES \
231+
-DCMAKE_DISABLE_FIND_PACKAGE_Doxygen=YES
218232
export PATH=$PWD/cov-analysis-linux64/bin:$PATH
219-
cov-build --dir cov-int cmake --build .
233+
cov-build --dir cov-int cmake --build build
220234
- name: Submit the result to Coverity Scan
221235
run: |
222236
tar czvf upload.tgz cov-int

README.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
2. Fetch the source
3030

31-
git clone --recursive https://github.com/open-eid/libdigidocpp
31+
git clone https://github.com/open-eid/libdigidocpp
3232
cd libdigidocpp
3333

3434
3. Configure
@@ -56,7 +56,7 @@
5656

5757
2. Fetch the source
5858

59-
git clone --recursive https://github.com/open-eid/libdigidocpp
59+
git clone https://github.com/open-eid/libdigidocpp
6060
cd libdigidocpp
6161

6262
3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64)
@@ -88,47 +88,56 @@
8888
* [Visual Studio Community 2019/2022](https://www.visualstudio.com/downloads/)
8989
* [CMake](http://www.cmake.org)
9090
* [vcpkg](https://vcpkg.io/)
91-
* [Swig](http://swig.org/download.html) - Optional, for C# and Java bindings
92-
* [Doxygen](https://www.doxygen.nl/download.html) - Optional, for generationg documentation
91+
* [Swig](http://swig.org/download.html) - Optional, for C#, Python and Java bindings
92+
* [Doxygen](https://www.doxygen.nl/download.html) - Optional, for generating documentation
9393
* [Wix toolset](http://wixtoolset.org/releases/) - Optional, for creating Windows installation packages
9494
* [Python](https://www.python.org/downloads/) - Optional, for Python bindings
9595
* [Java](https://www.oracle.com/java/technologies/downloads/) - Optional, for Java bindings
9696

97-
Toolset:
98-
* 142 - Visual Studio 2019 (Default)
99-
* 143 - Visual Studio 2022
97+
2. Open desired Visual Studio tools command prompt:
98+
* x64 Native Tool Command Prompt
99+
* x86 Native Tool Command Prompt
100+
* ARM64 Native Tool Command Prompt
101+
* Or some cross compile combination with target host type
100102

101-
2. Fetch the source
103+
3. Fetch the source
102104

103-
git clone --recursive https://github.com/open-eid/libdigidocpp
105+
git clone https://github.com/open-eid/libdigidocpp
104106
cd libdigidocpp
105107

106-
3. Configure
108+
4. Configure
107109

108110
cmake -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake `
109111
-DVCPKG_TARGET_TRIPLET=x64-windows `
110112
-DVCPKG_MANIFEST_FEATURES=tests `
111113
-B build -S .
112114

113-
Optional CMake parameters:
115+
Optional CMake parameters:
114116

115-
-DSWIG_EXECUTABLE=C:/swigwin-4.2.1/swig.exe
117+
-DSWIG_EXECUTABLE=C:/swigwin-4.2.1/swig.exe
118+
-DDOXYGEN_EXECUTABLE=C:/Program files/doxygen/bin/doxygen.exe
116119

117-
After running the cmake build, digidoc_csharp.dll along with the C# source files will be created, more info at
118-
[examples/DigiDocCSharp/README.md](examples/DigiDocCSharp/README.md).
120+
After running the cmake build, digidoc_csharp.dll along with the C# source files will be created, more info at
121+
[examples/DigiDocCSharp/README.md](examples/DigiDocCSharp/README.md).
119122

120-
4. Build
123+
5. Build
121124

122125
cmake --build build
123126

124-
5. Alternative to steps 4. and 5. -
127+
6. Alternative to steps 4. and 5. -
125128

126-
powershell -ExecutionPolicy ByPass -File build.ps1 -platform x64
129+
powershell -ExecutionPolicy ByPass -File build.ps1
130+
131+
Optional build.ps1 parameters:
132+
133+
-swig C:/swigwin-4.2.1/swig.exe
134+
-doxygen "C:/Program files/doxygen/bin/doxygen.exe"
135+
-boost
127136

128137
The build script builds executables and installation media for given
129138
platform (Debug and Release with debug symbols)
130139

131-
6. Execute
140+
7. Execute
132141

133142
build/src/digidoc-tool.exe
134143

build.ps1

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
#powershell -ExecutionPolicy ByPass -File build.ps1
22
param(
33
[string]$libdigidocpp = $PSScriptRoot,
4-
[string]$platform = "x64",
4+
[string]$platform = $env:VSCMD_ARG_TGT_ARCH,
5+
[string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}),
6+
[string]$msiversion = "4.1.0.$build_number",
7+
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi",
58
[string]$git = "git.exe",
69
[string]$vcpkg = "vcpkg\vcpkg.exe",
710
[string]$vcpkg_dir = (split-path -parent $vcpkg),
811
[string]$vcpkg_installed = $libdigidocpp,
912
[string]$vcpkg_installed_platform = "$vcpkg_installed\vcpkg_installed_$platform",
10-
[string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}),
11-
[string]$msiversion = "4.1.0.$build_number",
12-
[string]$msi_name = "libdigidocpp-$msiversion$env:VER_SUFFIX.$platform.msi",
13+
[string]$vcpkg_triplet = "$platform-windows",
1314
[string]$cmake = "cmake.exe",
1415
[string]$generator = "NMake Makefiles",
15-
[string]$vcvars = "vcvarsall",
1616
[string]$swig = $null,
1717
[string]$doxygen = $null,
1818
[switch]$boost = $false,
@@ -43,40 +43,49 @@ if($doxygen) {
4343
$cmakeext += "-DDOXYGEN_EXECUTABLE=$doxygen"
4444
$wixext += "-d", "docLocation=$(Get-Location)/$platform/share/doc/libdigidocpp"
4545
}
46+
if($env:VSCMD_ARG_HOST_ARCH -ne "arm64") {
47+
$cmakeext += "-DCMAKE_DISABLE_FIND_PACKAGE_Python3=yes"
48+
$wixext += "-d", "disablePython=1"
49+
if($platform -eq "arm64") {
50+
$boost = $false
51+
}
52+
}
4653
if($boost) {
4754
$cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests"
4855
$target += "check"
4956
}
5057

5158
foreach($type in @("Debug", "RelWithDebInfo")) {
5259
$buildpath = $platform+$type
53-
& $vcvars $platform "&&" $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" `
60+
& $cmake --fresh -B $buildpath -S $libdigidocpp "-G$generator" $cmakeext `
5461
"-DCMAKE_BUILD_TYPE=$type" `
5562
"-DCMAKE_INSTALL_PREFIX=$platform" `
5663
"-DCMAKE_INSTALL_LIBDIR=bin" `
5764
"-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake" `
5865
"-DVCPKG_INSTALLED_DIR=$vcpkg_installed_platform" `
59-
"-DSIGNCERT=$sign" `
60-
$cmakeext "&&" $cmake --build $buildpath --target $target "&&" $cmake --install $buildpath
66+
"-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" `
67+
"-DSIGNCERT=$sign"
68+
& $cmake --build $buildpath --target $target
69+
& $cmake --install $buildpath
6170
}
6271

6372
if($sign) {
64-
& $vcvars $platform "&&" signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee `
73+
& signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee `
6574
/tr http://timestamp.digicert.com /td SHA256 `
66-
$vcpkg_installed_platform/$platform-windows/bin/*.dll `
67-
$vcpkg_installed_platform/$platform-windows/debug/bin/*.dll
75+
$vcpkg_installed_platform/$vcpkg_triplet/bin/*.dll `
76+
$vcpkg_installed_platform/$vcpkg_triplet/debug/bin/*.dll
6877
}
6978

70-
& $vcvars $platform "&&" wix build -nologo -arch $platform -out $msi_name $wixext `
79+
& wix build -nologo -arch $platform -out $msi_name $wixext `
7180
-ext WixToolset.UI.wixext `
7281
-bv "WixUIBannerBmp=$libdigidocpp/banner.bmp" `
7382
-bv "WixUIDialogBmp=$libdigidocpp/dlgbmp.bmp" `
7483
-d "ICON=$libdigidocpp/ID.ico" `
75-
-d "vcpkg=$vcpkg_installed_platform/$platform-windows" `
84+
-d "vcpkg=$vcpkg_installed_platform/$vcpkg_triplet" `
7685
-d "libdigidocpp=$(Get-Location)/$platform" `
7786
$libdigidocpp\libdigidocpp.wxs
7887

7988
if($sign) {
80-
& $vcvars $platform "&&" signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee `
89+
& signtool.exe sign /a /v /s MY /n "$sign" /fd SHA256 /du http://installer.id.ee `
8190
/tr http://timestamp.digicert.com /td SHA256 "$msi_name"
8291
}

libdigidocpp.wxs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<?if $(sys.BUILDARCH) = x64 ?>
22
<?define UpgradeCode = "{93985BBA-6B59-443B-80C8-BA987407F8B8}" ?>
33
<?define OpenSSLSuffix = "-x64" ?>
4+
<?define Suffix = "" ?>
45
<?elseif $(sys.BUILDARCH) = arm64 ?>
56
<?define UpgradeCode = "{de2f0796-01fe-4291-bfc1-c01f631d082b}" ?>
67
<?define OpenSSLSuffix = "-arm64" ?>
8+
<?define Suffix = "-arm64" ?>
79
<?else?>
810
<?define UpgradeCode = "{7f1b1519-b527-4130-998d-233f4d050f14}" ?>
911
<?define OpenSSLSuffix = "" ?>
12+
<?define Suffix = "" ?>
1013
<?endif?>
1114

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

3336
<StandardDirectory Id="ProgramFiles6432Folder">
34-
<Directory Id="INSTALLFOLDER" Name="libdigidocpp" />
37+
<Directory Id="INSTALLFOLDER" Name="libdigidocpp$(var.Suffix)" />
3538
</StandardDirectory>
3639

3740
<ComponentGroup Id="Runtime"
@@ -60,8 +63,10 @@
6063
<?ifdef var.swig ?>
6164
<File Name="digidoc_csharp.dll" />
6265
<File Name="digidoc_java.dll" />
66+
<?ifndef var.disablePython ?>
6367
<File Name="_digidoc_python.pyd" />
6468
<File Name="digidoc.py" />
69+
<?endif?>
6570
<?endif?>
6671
</ComponentGroup>
6772

@@ -86,7 +91,9 @@
8691
<?ifdef var.swig ?>
8792
<File Name="digidoc_csharpd.dll" />
8893
<File Name="digidoc_javad.dll" />
94+
<?ifndef var.disablePython ?>
8995
<File Name="_digidoc_pythond.pyd" />
96+
<?endif?>
9097
<?endif?>
9198
</ComponentGroup>
9299

src/CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,17 @@ if(WIN32)
260260
install(FILES $<TARGET_PDB_FILE:digidocpp> $<TARGET_PDB_FILE:digidoc-tool> DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
261261
if(SIGNCERT)
262262
foreach(TARGET digidocpp digidoc-tool digidoc_java digidoc_csharp digidoc_python)
263-
if(CROSSSIGNCERT)
264-
target_link_options(${TARGET} PRIVATE "/INTEGRITYCHECK")
263+
if (TARGET ${TARGET})
264+
if(CROSSSIGNCERT)
265+
target_link_options(${TARGET} PRIVATE "/INTEGRITYCHECK")
266+
endif()
267+
add_custom_command(TARGET ${TARGET} POST_BUILD
268+
COMMAND signtool.exe sign /a /v /s MY /n "${SIGNCERT}" /fd SHA256 /du http://installer.id.ee
269+
"$<$<BOOL:${CROSSSIGNCERT}>:/ph;/ac;${CROSSSIGNCERT}>"
270+
/tr http://timestamp.digicert.com /td SHA256 $<TARGET_FILE:${TARGET}>
271+
COMMAND_EXPAND_LISTS
272+
)
265273
endif()
266-
add_custom_command(TARGET ${TARGET} POST_BUILD
267-
COMMAND signtool.exe sign /a /v /s MY /n "${SIGNCERT}" /fd SHA256 /du http://installer.id.ee
268-
"$<$<BOOL:${CROSSSIGNCERT}>:/ph;/ac;${CROSSSIGNCERT}>"
269-
/tr http://timestamp.digicert.com /td SHA256 $<TARGET_FILE:${TARGET}>
270-
COMMAND_EXPAND_LISTS
271-
)
272274
endforeach()
273275
endif()
274276
endif()

0 commit comments

Comments
 (0)