Skip to content

Commit

Permalink
Use vcpkg for android dependency tracking
Browse files Browse the repository at this point in the history
IB-8161

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Nov 6, 2024
1 parent 82eee1c commit 109098a
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 261 deletions.
41 changes: 37 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
target: [macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64]
target: [macos, iphoneos, iphonesimulator]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -32,9 +32,6 @@ jobs:
- name: Build openssl
if: steps.cache.outputs.cache-hit != 'true'
run: ./prepare_osx_build_environment.sh openssl ${{ matrix.target }}
- name: Build libxml2
if: steps.cache.outputs.cache-hit != 'true'
run: ./prepare_osx_build_environment.sh libxml2 ${{ matrix.target }}
- name: Build xmlsec
if: steps.cache.outputs.cache-hit != 'true'
run: ./prepare_osx_build_environment.sh xmlsec ${{ matrix.target }}
Expand Down Expand Up @@ -71,6 +68,42 @@ jobs:
with:
name: ${{ matrix.target }}
path: libdigidocpp*.zip
android:
name: Build on Ubuntu for ${{ matrix.target }}
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- target: androidarm
triplet: arm-neon-android
- target: androidarm64
triplet: arm64-android
- target: androidx86_64
triplet: x64-android
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 0f8b6ddf49fa8ae66a7826234e9ba3fda5f46d3c
vcpkgJsonGlob: ./vcpkg.json
runVcpkgInstall: true
env:
VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}
- name: Build
run: |
cmake --preset ${{ matrix.target }} "-GUnix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=libdigidocpp.${{ matrix.target }}
cmake --build --preset ${{ matrix.target }}
cmake --build --preset ${{ matrix.target }} --target install/strip
zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }}
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: libdigidocpp*.zip
fedora:
name: Build on Fedora ${{ matrix.container }}
runs-on: ubuntu-latest
Expand Down
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ find_package(MiniZip 1 QUIET)
add_library(xmlsec INTERFACE)
if(UNIX)
find_package(PkgConfig)
pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET)
target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL)
find_package(unofficial-xmlsec QUIET)
if(TARGET unofficial::xmlsec::xmlsec1-openssl)
target_link_libraries(xmlsec INTERFACE unofficial::xmlsec::xmlsec1-openssl)
else()
pkg_check_modules(XMLSEC1_OPENSSL xmlsec1-openssl REQUIRED IMPORTED_TARGET)
target_link_libraries(xmlsec INTERFACE PkgConfig::XMLSEC1_OPENSSL)
endif()
if(NOT APPLE)
pkg_check_modules(MINIZIP minizip IMPORTED_TARGET)
endif()
Expand Down
49 changes: 26 additions & 23 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
"displayName": "Default config",
"description": "Default build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}"
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "base",
"displayName": "macOS base build config",
"displayName": "Base build config",
"hidden": true,
"inherits": "default",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"environment": {
"DEST": "/Library/libdigidocpp$env{DEST_SUFFIX}"
},
"installDir": "$env{DEST}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_FIND_ROOT_PATH": "$env{DEST};/usr/local;/opt/homebrew"
}
"installDir": "$env{DEST}"
},
{
"name": "macos",
"inherits": "base",
"description": "This macos build is only available on macOS",
"inherits": "base",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
},
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
"CMAKE_OSX_DEPLOYMENT_TARGET": "12.0"
"CMAKE_OSX_DEPLOYMENT_TARGET": "12.0",
"CMAKE_FIND_ROOT_PATH": "$env{DEST}"
}
},
{
Expand All @@ -52,12 +52,11 @@
{
"name": "ios",
"hidden": true,
"inherits": "mobile",
"inherits": ["mobile", "macos"],
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "iOS",
"CMAKE_OSX_SYSROOT": "${presetName}",
"CMAKE_OSX_DEPLOYMENT_TARGET": "15.0",
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
"CMAKE_DISABLE_FIND_PACKAGE_SWIG": "YES",
"FRAMEWORK_DESTINATION": "$env{DEST}/lib"
}
Expand Down Expand Up @@ -91,31 +90,35 @@
"CMAKE_SYSTEM_NAME": "Android",
"CMAKE_SYSTEM_VERSION": "30",
"CMAKE_DISABLE_FIND_PACKAGE_Python3": "YES",
"BUILD_SHARED_LIBS": "NO"
"BUILD_SHARED_LIBS": "NO",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "androidarm",
"inherits": "android",
"description": "androidarm build is only available on macOS",
"description": "androidarm build",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a"
"CMAKE_ANDROID_ARCH_ABI": "armeabi-v7a",
"VCPKG_TARGET_TRIPLET": "arm-neon-android"
}
},
{
"name": "androidarm64",
"inherits": "android",
"description": "androidarm64 build is only available on macOS",
"description": "androidarm64 build",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "arm64-v8a"
"CMAKE_ANDROID_ARCH_ABI": "arm64-v8a",
"VCPKG_TARGET_TRIPLET": "arm64-android"
}
},
{
"name": "androidx86_64",
"inherits": "android",
"description": "androidx86_64 build is only available on macOS",
"description": "androidx86_64 build",
"cacheVariables": {
"CMAKE_ANDROID_ARCH_ABI": "x86_64"
"CMAKE_ANDROID_ARCH_ABI": "x86_64",
"VCPKG_TARGET_TRIPLET": "x64-android"
}
}
],
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,18 @@
### macOS

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

2. Fetch the source

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

3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator, androidarm, androidarm64, androidx86_64)
3. Prepare dependencies (available targets: macos, iphoneos, iphonesimulator)

sh prepare_osx_build_environment.sh macos all

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.cert.X509Certificate;
import java.sql.Timestamp;
import java.util.Objects;
Expand Down Expand Up @@ -59,14 +60,14 @@ protected void onCreate(Bundle savedInstanceState) {
try (ZipInputStream zis = new ZipInputStream(getResources().openRawResource(R.raw.schema))) {
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
Files.copy(zis, Paths.get(cache, ze.getName()));
Files.copy(zis, Paths.get(cache, ze.getName()), StandardCopyOption.REPLACE_EXISTING);
}
}
try (InputStream in = getResources().openRawResource(R.raw.test)) {
Files.copy(in, Paths.get(cache, "test.bdoc"));
Files.copy(in, Paths.get(cache, "test.bdoc"), StandardCopyOption.REPLACE_EXISTING);
}
try (ByteArrayInputStream bin = new ByteArrayInputStream(new byte[] {})) {
Files.copy(bin, Paths.get(cache, "EE_T.xml"));
Files.copy(bin, Paths.get(cache, "EE_T.xml"), StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
e.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion examples/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.5.2'
classpath 'com.android.tools.build:gradle:8.7.2'
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
Loading

0 comments on commit 109098a

Please sign in to comment.