Skip to content

Commit a708f24

Browse files
authored
Use vcpkg for android dependency tracking (#620)
IB-8161 Signed-off-by: Raul Metsma <[email protected]>
1 parent e7bbc30 commit a708f24

File tree

12 files changed

+130
-261
lines changed

12 files changed

+130
-261
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: macos-latest
1515
strategy:
1616
matrix:
17-
target: [macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64]
17+
target: [macos, iphoneos, iphonesimulator]
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v4
@@ -35,9 +35,6 @@ jobs:
3535
- name: Build openssl
3636
if: steps.cache.outputs.cache-hit != 'true'
3737
run: ./prepare_osx_build_environment.sh openssl ${{ matrix.target }}
38-
- name: Build libxml2
39-
if: steps.cache.outputs.cache-hit != 'true'
40-
run: ./prepare_osx_build_environment.sh libxml2 ${{ matrix.target }}
4138
- name: Build xmlsec
4239
if: steps.cache.outputs.cache-hit != 'true'
4340
run: ./prepare_osx_build_environment.sh xmlsec ${{ matrix.target }}
@@ -69,6 +66,42 @@ jobs:
6966
path: |
7067
build/*/libdigidocpp*.*
7168
libdigidocpp*.zip
69+
android:
70+
name: Build on Ubuntu for ${{ matrix.target }}
71+
runs-on: ubuntu-24.04
72+
strategy:
73+
matrix:
74+
include:
75+
- target: androidarm
76+
triplet: arm-neon-android
77+
- target: androidarm64
78+
triplet: arm64-android
79+
- target: androidx86_64
80+
triplet: x64-android
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v4
84+
- name: Prepare vcpkg
85+
uses: lukka/run-vcpkg@v11
86+
with:
87+
vcpkgGitCommitId: e2edf52610d2c94d2038fe30b247ea5a26964e1b
88+
vcpkgJsonGlob: ./vcpkg.json
89+
runVcpkgInstall: true
90+
env:
91+
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
92+
- name: Build
93+
run: |
94+
cmake --preset ${{ matrix.target }} "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=libdigidocpp.${{ matrix.target }}
95+
cmake --build --preset ${{ matrix.target }}
96+
cmake --build --preset ${{ matrix.target }} --target install/strip
97+
zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }}
98+
- name: Archive artifacts
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: ${{ matrix.target }}
102+
path: |
103+
build/macos/libdigidocpp*.*
104+
libdigidocpp*.zip
72105
fedora:
73106
name: Build on Fedora ${{ matrix.container }}
74107
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ find_package(MiniZip 1 QUIET)
6565
add_library(xmlsec INTERFACE)
6666
if(UNIX)
6767
find_package(PkgConfig)
68-
pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET)
69-
target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL)
68+
find_package(unofficial-xmlsec QUIET)
69+
if(TARGET unofficial::xmlsec::xmlsec1-openssl)
70+
target_link_libraries(xmlsec INTERFACE unofficial::xmlsec::xmlsec1-openssl)
71+
else()
72+
pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET)
73+
target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL)
74+
endif()
7075
if(NOT APPLE)
7176
pkg_check_modules(MINIZIP minizip IMPORTED_TARGET)
7277
endif()

CMakePresets.json

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66
"displayName": "Default config",
77
"description": "Default build using Ninja generator",
88
"generator": "Ninja",
9-
"binaryDir": "${sourceDir}/build/${presetName}"
9+
"binaryDir": "${sourceDir}/build/${presetName}",
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug"
12+
}
1013
},
1114
{
1215
"name": "base",
13-
"displayName": "macOS base build config",
16+
"displayName": "Base build config",
1417
"hidden": true,
1518
"inherits": "default",
16-
"condition": {
17-
"type": "equals",
18-
"lhs": "${hostSystemName}",
19-
"rhs": "Darwin"
20-
},
2119
"environment": {
2220
"DEST": "/Library/libdigidocpp$env{DEST_SUFFIX}"
2321
},
24-
"installDir": "$env{DEST}",
25-
"cacheVariables": {
26-
"CMAKE_BUILD_TYPE": "Debug",
27-
"CMAKE_FIND_ROOT_PATH": "$env{DEST};/usr/local;/opt/homebrew"
28-
}
22+
"installDir": "$env{DEST}"
2923
},
3024
{
3125
"name": "macos",
32-
"inherits": "base",
3326
"description": "This macos build is only available on macOS",
27+
"inherits": "base",
28+
"condition": {
29+
"type": "equals",
30+
"lhs": "${hostSystemName}",
31+
"rhs": "Darwin"
32+
},
3433
"cacheVariables": {
3534
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
36-
"CMAKE_OSX_DEPLOYMENT_TARGET": "12.0"
35+
"CMAKE_OSX_DEPLOYMENT_TARGET": "12.0",
36+
"CMAKE_FIND_ROOT_PATH": "$env{DEST}"
3737
}
3838
},
3939
{
@@ -52,12 +52,11 @@
5252
{
5353
"name": "ios",
5454
"hidden": true,
55-
"inherits": "mobile",
55+
"inherits": ["mobile", "macos"],
5656
"cacheVariables": {
5757
"CMAKE_SYSTEM_NAME": "iOS",
5858
"CMAKE_OSX_SYSROOT": "${presetName}",
5959
"CMAKE_OSX_DEPLOYMENT_TARGET": "15.0",
60-
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
6160
"CMAKE_DISABLE_FIND_PACKAGE_SWIG": "YES",
6261
"FRAMEWORK_DESTINATION": "$env{DEST}/lib"
6362
}
@@ -91,31 +90,35 @@
9190
"CMAKE_SYSTEM_NAME": "Android",
9291
"CMAKE_SYSTEM_VERSION": "30",
9392
"CMAKE_DISABLE_FIND_PACKAGE_Python3": "YES",
94-
"BUILD_SHARED_LIBS": "NO"
93+
"BUILD_SHARED_LIBS": "NO",
94+
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
9595
}
9696
},
9797
{
9898
"name": "androidarm",
9999
"inherits": "android",
100-
"description": "androidarm build is only available on macOS",
100+
"description": "androidarm build",
101101
"cacheVariables": {
102-
"CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a"
102+
"CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a",
103+
"VCPKG_TARGET_TRIPLET": "arm-neon-android"
103104
}
104105
},
105106
{
106107
"name": "androidarm64",
107108
"inherits": "android",
108-
"description": "androidarm64 build is only available on macOS",
109+
"description": "androidarm64 build",
109110
"cacheVariables": {
110-
"CMAKE_ANDROID_ARCH_ABI": "arm64-v8a"
111+
"CMAKE_ANDROID_ARCH_ABI": "arm64-v8a",
112+
"VCPKG_TARGET_TRIPLET": "arm64-android"
111113
}
112114
},
113115
{
114116
"name": "androidx86_64",
115117
"inherits": "android",
116-
"description": "androidx86_64 build is only available on macOS",
118+
"description": "androidx86_64 build",
117119
"cacheVariables": {
118-
"CMAKE_ANDROID_ARCH_ABI": "x86_64"
120+
"CMAKE_ANDROID_ARCH_ABI": "x86_64",
121+
"VCPKG_TARGET_TRIPLET": "x64-android"
119122
}
120123
}
121124
],

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,18 @@
5050
### macOS
5151

5252
1. Install dependencies from
53-
* [XCode](https://itunes.apple.com/en/app/xcode/id497799835?mt=12)
53+
* [XCode](https://itunes.apple.com/en/app/xcode/id497799835?mt=12) - For macOS/iOS development
5454
* [CMake](http://www.cmake.org)
5555
* [Homebrew](https://brew.sh)
56+
* [vcpkg](https://vcpkg.io/) - For Android development (VCPKG_ROOT)
57+
* [Android NDK](https://developer.android.com/ndk/downloads) - For Android development (ANDROID_NDK_ROOT)
5658

5759
2. Fetch the source
5860

5961
git clone https://github.com/open-eid/libdigidocpp
6062
cd libdigidocpp
6163

62-
3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64)
64+
3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator)
6365

6466
sh prepare_osx_build_environment.sh macos all
6567

examples/android/app/src/main/java/ee/ria/libdigidocpp/MainActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.nio.charset.StandardCharsets;
2929
import java.nio.file.Files;
3030
import java.nio.file.Paths;
31+
import java.nio.file.StandardCopyOption;
3132
import java.security.cert.X509Certificate;
3233
import java.sql.Timestamp;
3334
import java.util.Objects;
@@ -59,14 +60,14 @@ protected void onCreate(Bundle savedInstanceState) {
5960
try (ZipInputStream zis = new ZipInputStream(getResources().openRawResource(R.raw.schema))) {
6061
ZipEntry ze;
6162
while ((ze = zis.getNextEntry()) != null) {
62-
Files.copy(zis, Paths.get(cache, ze.getName()));
63+
Files.copy(zis, Paths.get(cache, ze.getName()), StandardCopyOption.REPLACE_EXISTING);
6364
}
6465
}
6566
try (InputStream in = getResources().openRawResource(R.raw.test)) {
66-
Files.copy(in, Paths.get(cache, "test.bdoc"));
67+
Files.copy(in, Paths.get(cache, "test.bdoc"), StandardCopyOption.REPLACE_EXISTING);
6768
}
6869
try (ByteArrayInputStream bin = new ByteArrayInputStream(new byte[] {})) {
69-
Files.copy(bin, Paths.get(cache, "EE_T.xml"));
70+
Files.copy(bin, Paths.get(cache, "EE_T.xml"), StandardCopyOption.REPLACE_EXISTING);
7071
}
7172
} catch (IOException e) {
7273
e.printStackTrace();

examples/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
mavenCentral()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:8.5.2'
8+
classpath 'com.android.tools.build:gradle:8.7.3'
99
}
1010
}
1111

examples/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip

0 commit comments

Comments
 (0)