Skip to content

Commit 4a9daa4

Browse files
committed
Use vcpkg for android dependency tracking
IB-8161 Signed-off-by: Raul Metsma <[email protected]>
1 parent 826d8a2 commit 4a9daa4

File tree

13 files changed

+139
-266
lines changed

13 files changed

+139
-266
lines changed

.github/workflows/build.yml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: macos-latest
1313
strategy:
1414
matrix:
15-
target: [macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64]
15+
target: [macos, iphoneos, iphonesimulator]
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
@@ -34,9 +34,6 @@ jobs:
3434
- name: Build openssl
3535
if: steps.cache.outputs.cache-hit != 'true'
3636
run: ./prepare_osx_build_environment.sh openssl ${{ matrix.target }}
37-
- name: Build libxml2
38-
if: steps.cache.outputs.cache-hit != 'true'
39-
run: ./prepare_osx_build_environment.sh libxml2 ${{ matrix.target }}
4037
- name: Build xmlsec
4138
if: steps.cache.outputs.cache-hit != 'true'
4239
run: ./prepare_osx_build_environment.sh xmlsec ${{ matrix.target }}
@@ -73,6 +70,42 @@ jobs:
7370
with:
7471
name: ${{ matrix.target }}
7572
path: libdigidocpp*.zip
73+
android:
74+
name: Build on Ubuntu for ${{ matrix.target }}
75+
runs-on: ubuntu-24.04
76+
strategy:
77+
matrix:
78+
include:
79+
- target: androidarm
80+
triplet: arm-neon-android
81+
- target: androidarm64
82+
triplet: arm64-android
83+
- target: androidx86_64
84+
triplet: x64-android
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v4
88+
with:
89+
submodules: recursive
90+
- name: Prepare vcpkg
91+
uses: lukka/run-vcpkg@v11
92+
with:
93+
vcpkgGitCommitId: 0f8b6ddf49fa8ae66a7826234e9ba3fda5f46d3c
94+
vcpkgJsonGlob: ./vcpkg.json
95+
runVcpkgInstall: true
96+
env:
97+
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
98+
- name: Build
99+
run: |
100+
cmake --preset ${{ matrix.target }} "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=libdigidocpp.${{ matrix.target }}
101+
cmake --build --preset ${{ matrix.target }}
102+
cmake --build --preset ${{ matrix.target }} --target install/strip
103+
zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }}
104+
- name: Archive artifacts
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: ${{ matrix.target }}
108+
path: libdigidocpp*.zip
76109
fedora:
77110
name: Build on Fedora ${{ matrix.container }}
78111
runs-on: ubuntu-latest

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,16 @@ find_package(MiniZip 1 QUIET)
5757
add_library(xmlsec INTERFACE)
5858
if(UNIX)
5959
find_package(PkgConfig)
60-
pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET)
61-
target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL)
60+
find_package(unofficial-xmlsec QUIET)
61+
if(TARGET unofficial::xmlsec::xmlsec1-openssl)
62+
target_link_libraries(xmlsec INTERFACE
63+
unofficial::xmlsec::xmlsec1
64+
unofficial::xmlsec::xmlsec1-openssl
65+
)
66+
else()
67+
pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET)
68+
target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL)
69+
endif()
6270
if(NOT APPLE)
6371
pkg_check_modules(MINIZIP minizip IMPORTED_TARGET)
6472
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 --recursive 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.0'
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)