Skip to content
Open
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
50 changes: 35 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
target: [macos, iphoneos, iphonesimulator]
include:
- target: macos
- target: iphoneos
triplet: arm64-ios
- target: iphonesimulator
triplet: arm64-x64-ios-simulator
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -29,39 +34,50 @@ jobs:
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.13
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.14
- name: Cache
if: matrix.target == 'macos'
uses: actions/cache@v5
id: cache
with:
path: cache
key: ${{ matrix.target }}-${{ hashFiles('prepare_osx_build_environment.sh') }}
- name: Cache vcpkg
if: matrix.target != 'macos'
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-${{ matrix.target }}-${{ hashFiles('vcpkg.json') }}
- name: Build openssl
if: steps.cache.outputs.cache-hit != 'true'
if: matrix.target == 'macos' && steps.cache.outputs.cache-hit != 'true'
run: ./prepare_osx_build_environment.sh openssl ${{ matrix.target }}
- name: Build xmlsec
if: steps.cache.outputs.cache-hit != 'true'
if: matrix.target == 'macos' && steps.cache.outputs.cache-hit != 'true'
run: ./prepare_osx_build_environment.sh xmlsec ${{ matrix.target }}
- name: Move to cache
if: steps.cache.outputs.cache-hit != 'true'
if: matrix.target == 'macos' && steps.cache.outputs.cache-hit != 'true'
run: |
mkdir cache
sudo mv /Library/libdigidocpp* cache
- name: Setup cache
run: sudo ln -s $PWD/cache/* /Library/
- name: Build macOS
if: matrix.target == 'macos'
run: |
sudo ln -s $PWD/cache/* /Library/
cmake --preset ${{ matrix.target }} -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build --preset ${{ matrix.target }}
cmake --build --preset ${{ matrix.target }} --target test pkcs11sign embedlibs
cmake --build --preset ${{ matrix.target }} --target test pkcs11sign embedlibs
cmake --build --preset ${{ matrix.target }} --target zipdebug pkgbuild
- name: Build ${{ matrix.target }}
if: matrix.target != 'macos'
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
run: |
export VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT
cmake --preset ${{ matrix.target }} -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build --preset ${{ matrix.target }}
sudo cmake --build --preset ${{ matrix.target }} --target install/strip
cd /Library
zip -q -r ${OLDPWD}/libdigidocpp.${{ matrix.target }}.zip libdigidocpp.*
cmake --build --preset ${{ matrix.target }} --target install/strip
mkdir -p libdigidocpp.${{ matrix.target }}/include
cp build/${{ matrix.target }}/vcpkg_installed/${{ matrix.triplet }}/lib/{libcrypto,libssl}.a libdigidocpp.${{ matrix.target }}/lib/
cp -r build/${{ matrix.target }}/vcpkg_installed/${{ matrix.triplet }}/include/openssl libdigidocpp.${{ matrix.target }}/include/
zip -q -r libdigidocpp.${{ matrix.target }}.zip libdigidocpp.${{ matrix.target }}
- name: Archive artifacts
uses: actions/upload-artifact@v6
with:
Expand All @@ -88,7 +104,7 @@ jobs:
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-${{ matrix.target }}-${{ hashFiles('vcpkg.json', 'vcpkg-ports/**') }}
key: vcpkg-${{ matrix.target }}-${{ hashFiles('vcpkg.json') }}
- name: Build
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
Expand Down Expand Up @@ -151,6 +167,9 @@ jobs:
steps:
- name: Install dependencies
run: |
for f in /etc/apt/sources.list /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources; do
[ -f "$f" ] && sed -i 's|http://archive.ubuntu.com|http://azure.archive.ubuntu.com|g; s|http://security.ubuntu.com|http://azure.archive.ubuntu.com|g' "$f"
done
echo 'path-exclude=/usr/share/man/*' > /etc/dpkg/dpkg.cfg.d/99-nodocs
echo 'path-exclude=/usr/share/doc/*' >> /etc/dpkg/dpkg.cfg.d/99-nodocs
echo 'path-exclude=/usr/share/doc-base/*' >> /etc/dpkg/dpkg.cfg.d/99-nodocs
Expand All @@ -175,10 +194,10 @@ jobs:
path: libdigidocpp*.*
windows:
name: Build on Windows
runs-on: windows-2025
runs-on: windows-2025${{ matrix.toolset == '145' && '-vs2026' || '' }}
strategy:
matrix:
toolset: [143]
toolset: [143, 145]
platform: [x86, x64, arm64]
include:
- platform: x86
Expand All @@ -200,7 +219,7 @@ jobs:
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/vcpkg_cache
key: vcpkg-${{ matrix.toolset }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json', 'vcpkg-ports/**') }}
key: vcpkg-${{ matrix.toolset }}-${{ matrix.platform }}-${{ hashFiles('vcpkg.json') }}
- name: Install dependencies
run: winget install --silent --accept-source-agreements --accept-package-agreements swig doxygen 9NQ7512CXL7T
- uses: actions/setup-java@v5
Expand All @@ -213,7 +232,8 @@ jobs:
run: |
& "$env:LOCALAPPDATA\Microsoft\WindowsApps\py.exe" install --target=.\python\${{ matrix.platform }} 3.13-${{ matrix.python }}
$swig = (Get-Item "$env:LOCALAPPDATA\Microsoft\WinGet\Links\swig.exe").Target
& "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat" ${{ matrix.setenv }} "&&" pwsh build.ps1 `
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
& "$vsPath\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.setenv }} "&&" pwsh build.ps1 `
-vcpkg "C:/vcpkg/vcpkg.exe" `
-swig $swig `
-doxygen "C:/Program files/doxygen/bin/doxygen.exe" `
Expand Down
23 changes: 14 additions & 9 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,24 @@
"inherits": "default",
"installDir": "$env{DEST}",
"environment": {
"DEST": "libdigidocpp$env{DEST_SUFFIX}",
"DEST": "${sourceDir}/libdigidocpp$env{DEST_SUFFIX}",
"DEST_SUFFIX": ".${presetName}"
},
"cacheVariables": {
"CMAKE_DISABLE_FIND_PACKAGE_Boost": "YES",
"CMAKE_DISABLE_FIND_PACKAGE_Doxygen": "YES",
"BUILD_TOOLS": "NO"
"BUILD_TOOLS": "NO",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
{
"name": "ios",
"hidden": true,
"inherits": ["macos", "mobile"],
"inherits": ["mobile","macos"],
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "iOS",
"CMAKE_OSX_SYSROOT": "${presetName}",
"CMAKE_OSX_DEPLOYMENT_TARGET": "15.0",
"CMAKE_OSX_DEPLOYMENT_TARGET": "16.0",
"CMAKE_DISABLE_FIND_PACKAGE_SWIG": "YES",
"FRAMEWORK_DESTINATION": "$env{DEST}/lib"
}
Expand All @@ -62,20 +63,25 @@
"inherits": "ios",
"description": "This iphoneos build is only available on macOS",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "arm64"
"CMAKE_OSX_ARCHITECTURES": "arm64",
"VCPKG_TARGET_TRIPLET": "arm64-ios"
}
},
{
"name": "iphonesimulator",
"inherits": "ios",
"description": "This iphonesimulator build is only available on macOS"
"description": "This iphonesimulator build is only available on macOS",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-x64-ios-simulator"
}
},
{
"name": "iphonecatalyst",
"inherits": "ios",
"description": "This iphonecatalyst build is only available on macOS",
"cacheVariables": {
"CMAKE_OSX_SYSROOT": "macosx"
"CMAKE_OSX_SYSROOT": "macosx",
"VCPKG_TARGET_TRIPLET": "arm64-x64-ios-catalyst"
}
},
{
Expand All @@ -86,8 +92,7 @@
"CMAKE_SYSTEM_NAME": "Android",
"CMAKE_SYSTEM_VERSION": "30",
"CMAKE_DISABLE_FIND_PACKAGE_Python3": "YES",
"BUILD_SHARED_LIBS": "NO",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"BUILD_SHARED_LIBS": "NO"
}
},
{
Expand Down
70 changes: 52 additions & 18 deletions examples/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
apply plugin: 'com.android.application'

def libsPath = '/Library/libdigidocpp'
def projectRoot = rootDir.parentFile.parentFile.absolutePath
def cmakeInstall = "${projectDir}/build/cmake"

def localProps = new Properties()
def localPropsFile = rootDir.toPath().resolve('local.properties').toFile()
if (localPropsFile.exists()) localProps.load(localPropsFile.newDataInputStream())
def cmake = localProps.getProperty('cmake') ?: {
def sdkCmake = new File(localProps.getProperty('sdk.dir', ''), 'cmake')
sdkCmake.listFiles()?.collect { new File(it, 'bin/cmake') }?.find { it.exists() }?.absolutePath ?: 'cmake'
}()

android {
compileSdk = 36
Expand All @@ -14,7 +23,6 @@ android {
versionCode Integer.parseInt(System.getenv("BUILD_NUMBER"))
versionName "1.0." + System.getenv("BUILD_NUMBER")
}
setProperty("archivesBaseName", "libdigidocpp-android-$versionName")
}
buildTypes {
release {
Expand All @@ -26,33 +34,59 @@ android {
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_17
}
sourceSets.main.java.srcDirs += [libsPath + '.androidarm64/include']
sourceSets.main.java.srcDirs += ["${cmakeInstall}/androidarm64/include"]
namespace 'ee.ria.libdigidocpp'
}

def versionNameValue = System.getenv("BUILD_NUMBER") ? "1.0.${System.getenv('BUILD_NUMBER')}" : "1.0"

androidComponents {
onVariants(selector().all()) { variant ->
variant.outputs.forEach { output ->
output.outputFileName.set("libdigidocpp-android-${versionNameValue}.apk")
}
}
}

[[preset: 'androidarm', jniDir: 'armeabi-v7a'],
[preset: 'androidarm64', jniDir: 'arm64-v8a'],
[preset: 'androidx86_64', jniDir: 'x86_64']].each { cfg ->

def configureTask = tasks.register("cmakeConfigure_${cfg.preset}", Exec) {
inputs.files("${projectRoot}/CMakePresets.json", "${projectRoot}/CMakeLists.txt", "${projectRoot}/vcpkg.json")
outputs.dir("${projectRoot}/build/${cfg.preset}")
workingDir projectRoot
commandLine cmake, '--preset', cfg.preset,
'-DCMAKE_BUILD_TYPE=RelWithDebInfo',
"-DCMAKE_INSTALL_PREFIX=${cmakeInstall}/${cfg.preset}"
}

tasks.register("cmakeBuild_${cfg.preset}", Exec) {
dependsOn configureTask
inputs.dir("${projectRoot}/build/${cfg.preset}")
outputs.dir("${cmakeInstall}/${cfg.preset}")
workingDir projectRoot
commandLine cmake, '--build', '--preset', cfg.preset, '--target', 'install'
}

tasks.register("copyLib_${cfg.preset}", Copy) {
dependsOn "cmakeBuild_${cfg.preset}"
from "${cmakeInstall}/${cfg.preset}/lib/libdigidoc_java.so"
into "src/main/jniLibs/${cfg.jniDir}"
}
}

tasks.register('schemaZip', Zip) {
println "Create schema zip"
from(libsPath + '.androidarm/etc/digidocpp/schema/') {
dependsOn 'cmakeBuild_androidarm'
from("${cmakeInstall}/androidarm/etc/digidocpp/schema/") {
include '*'
}
destinationDirectory = file('src/main/res/raw/')
archiveFileName = 'schema.zip'
}

tasks.register('copyLibs') {
println "Copy jniLibs"
copy {
from libsPath + '.androidarm/lib/libdigidoc_java.so'
into 'src/main/jniLibs/armeabi-v7a'
}
copy {
from libsPath + '.androidarm64/lib/libdigidoc_java.so'
into 'src/main/jniLibs/arm64-v8a'
}
copy {
from libsPath + '.androidx86_64/lib/libdigidoc_java.so'
into 'src/main/jniLibs/x86_64'
}
dependsOn 'copyLib_androidarm', 'copyLib_androidarm64', 'copyLib_androidx86_64'
}

preBuild.dependsOn schemaZip, copyLibs
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.13.0'
classpath 'com.android.tools.build:gradle:9.1.1'
}
}

Expand Down
5 changes: 4 additions & 1 deletion examples/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
org.gradle.unsafe.configuration-cache=true
android.nonTransitiveRClass=true
android.nonFinalResIds=true
android.nonFinalResIds=true
android.uniquePackageNames=false
android.dependency.useConstraints=true
android.r8.strictFullModeForKeepRules=false
13 changes: 13 additions & 0 deletions examples/android/gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/56a19bc915b9ba2eb62ba7554c61b919/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/398ffe3949748bfb1d5636f023d228fd/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/56a19bc915b9ba2eb62ba7554c61b919/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/398ffe3949748bfb1d5636f023d228fd/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/e99bae143b75f9a10ead10248f02055e/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/04e088f8677de3b384108493cc9481d0/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/56a19bc915b9ba2eb62ba7554c61b919/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/398ffe3949748bfb1d5636f023d228fd/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/e55dccbfe27cb97945148c61a39c89c5/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/dbd05c4936d573642f94cd149e1356c8/redirect
toolchainVendor=JETBRAINS
toolchainVersion=21
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.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
3 changes: 3 additions & 0 deletions examples/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down
9 changes: 3 additions & 6 deletions examples/ios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
### macOS

1. Install dependencies see [README.md](../../README.md#macOS)
2. Build example
2. Build example and run on simulator

xcodebuild -project libdigidocpp.xcodeproj

3. Execute

Open Xcode project and run on simulator
xcodebuild -project libdigidocpp.xcodeproj -sdk iphonesimulator

Or open the Xcode project and run on a simulator or device directly.

AppDelegate.mm contains how to override digidoc::XmlConf to point right cache folder for TSL lists.
Loading
Loading