Skip to content

Commit 77acd20

Browse files
committed
fix: align anoncreds build.gradle.kts with askar and indy-vdr patterns
Signed-off-by: Carine Bertagnolli Bathaglini <cbbathaglini@gmail.com>
1 parent a2202d9 commit 77acd20

2 files changed

Lines changed: 35 additions & 31 deletions

File tree

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ And add the following dependency to your target:
3333

3434
Take a look at the tests in `swift/Tests` directory for examples on how to use the wrappers.
3535

36-
#### Building AnonCreds for iOS
37-
38-
The AnonCreds Swift framework is built with `anoncreds/build-swift-framework.sh`.
39-
The script pins the minimum iOS deployment target to `15.0` and macOS to `12.0` before running `cargo build` for each Apple target.
40-
41-
This is required with newer Xcode SDKs because dependencies such as `openssl-sys` can otherwise be compiled for a newer iOS SDK while the final Rust static library is linked as iOS `10.0`. The typical failure looks like this:
42-
43-
```text
44-
object file (...) was built for newer 'iOS' version (26.0) than being linked (10.0)
45-
Undefined symbols for architecture arm64:
46-
"___chkstk_darwin"
47-
```
48-
49-
The script sets `IPHONEOS_DEPLOYMENT_TARGET`, `MACOSX_DEPLOYMENT_TARGET`, and target-specific `RUSTFLAGS` (`-miphoneos-version-min`, `-mios-simulator-version-min`, or `-mmacosx-version-min`) so Rust and clang link all slices with compatible deployment targets.
5036

5137
### Kotlin
5238

kotlin/anoncreds/build.gradle.kts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import gobley.gradle.GobleyHost
22
import gobley.gradle.Variant
3+
import gobley.gradle.cargo.dsl.android
34
import gobley.gradle.cargo.dsl.appleMobile
45
import gobley.gradle.cargo.dsl.jvm
56
import gobley.gradle.cargo.dsl.linux
7+
import gobley.gradle.cargo.dsl.macos
68
import gobley.gradle.rust.targets.RustPosixTarget
79
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
810
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
911
import java.util.Properties
1012

11-
1213
plugins {
1314
alias(libs.plugins.kotlinMultiplatform)
1415
alias(libs.plugins.kotlinSerialization)
@@ -27,28 +28,48 @@ cargo {
2728
jvmVariant = Variant.Release
2829
nativeVariant = Variant.Release
2930

30-
// Use cross when building Linux
3131
val home = System.getProperty("user.home")
32-
val crossFile = File("$home/.cargo/bin/cross")
32+
3333
builds {
3434
linux {
35+
val crossFile = File("$home/.cargo/bin/cross")
3536
variants {
3637
buildTaskProvider.configure {
3738
cargo = crossFile
3839
}
3940
}
4041
}
41-
}
42-
builds {
42+
43+
macos {
44+
release.buildTaskProvider.configure{
45+
additionalEnvironment.put("CC", "clang")
46+
additionalEnvironment.put("CXX", "clang++")
47+
additionalEnvironment.put("CFLAGS", "-Wno-error=deprecated")
48+
additionalEnvironment.put("CXXFLAGS", "-Wno-error=deprecated")
49+
}
50+
}
51+
4352
appleMobile {
4453
release.buildTaskProvider.configure {
45-
additionalEnvironment.put("IPHONEOS_DEPLOYMENT_TARGET", "10")
54+
additionalEnvironment.put("IPHONEOS_DEPLOYMENT_TARGET", "10.0")
55+
additionalEnvironment.put("CC", "clang")
56+
additionalEnvironment.put("CXX", "clang++")
57+
}
58+
}
59+
60+
android {
61+
dynamicLibraries.addAll("c++_shared")
62+
variants{
63+
buildTaskProvider.configure {
64+
// Required by Google Play for native libraries on 16 KB page-size devices.
65+
additionalEnvironment.put("RUSTFLAGS", "-C link-args=-Wl,-z,max-page-size=16384")
66+
}
4667
}
4768
}
69+
4870
jvm {
4971
embedRustLibrary = true
5072
if (GobleyHost.Platform.MacOS.isCurrent) {
51-
// Don't build for linux or windows on MacOS (mainly for github actions purposes)
5273
val exclude = listOf(
5374
RustPosixTarget.MinGWX64,
5475
RustPosixTarget.LinuxArm64,
@@ -99,10 +120,10 @@ publishing {
99120
maven {
100121
name = "github"
101122
setUrl("https://maven.pkg.github.com/LF-Decentralized-Trust-labs/aries-uniffi-wrappers")
102-
credentials {
103-
username = getExtraString("githubUsername")
104-
password = getExtraString("githubToken")
105-
}
123+
credentials {
124+
username = getExtraString("githubUsername") ?: ""
125+
password = getExtraString("githubToken") ?: ""
126+
}
106127
}
107128
}
108129

@@ -135,10 +156,6 @@ publishing {
135156
}
136157
}
137158

138-
tasks.matching { it.name.startsWith("publishAnoncredsUniffiPublicationTo") }
139-
.configureEach { dependsOn("assembleRelease") }
140-
141-
142159
kotlin {
143160
jvmToolchain(17)
144161
applyDefaultHierarchyTemplate()
@@ -183,7 +200,7 @@ kotlin {
183200
val commonTest by getting {
184201
dependencies {
185202
implementation(kotlin("test"))
186-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
203+
implementation(libs.kotlinx.coroutines.core)
187204
}
188205
}
189206

@@ -208,9 +225,10 @@ kotlin {
208225

209226

210227
android {
228+
sourceSets["androidTest"].manifest.srcFile("src/androidTest/AndroidManifest.xml")
211229
namespace = "anoncreds_uniffi"
212230
compileSdk = 35
213-
ndkVersion = "26.1.10909125"
231+
ndkVersion = "28.2.13676358"
214232

215233
defaultConfig {
216234
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

0 commit comments

Comments
 (0)