-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move uniffi generated code into a separate library
By moving the code into its own library we can control the visibility by importing it into our public facing library as an implementation dependency. This makes our wrapper API the only visible API to the library consumer.
- Loading branch information
Showing
12 changed files
with
141 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ pluginManagement { | |
} | ||
} | ||
|
||
include("jvm", "android") | ||
include("jvm", "android", "uniffi-jvm", "uniffi-android") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
plugins { | ||
id("com.android.library") | ||
kotlin("android") | ||
id("com.vanniktech.maven.publish") | ||
} | ||
|
||
dependencies { | ||
implementation(platform(kotlin("bom"))) | ||
implementation(platform(libs.coroutines.bom)) | ||
implementation(kotlin("stdlib-jdk7")) | ||
implementation("${libs.jna.get()}@aar") | ||
implementation(libs.appCompat) | ||
implementation(libs.ktx.core) | ||
implementation(libs.coroutines.core) | ||
implementation(libs.slf4j) | ||
testImplementation(kotlin("test")) | ||
testImplementation(libs.android.logback) | ||
testImplementation(libs.android.junit) | ||
testImplementation(libs.espresso) | ||
testImplementation(libs.coroutines.test) | ||
testImplementation(libs.assertj.core) | ||
} | ||
|
||
android { | ||
namespace = "com.wire.crypto" | ||
compileSdk = libs.versions.sdk.compile.get().toInt() | ||
defaultConfig { | ||
minSdk = libs.versions.sdk.min.get().toInt() | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = false | ||
proguardFiles(file("proguard-android-optimize.txt"), file("proguard-rules.pro")) | ||
} | ||
} | ||
} | ||
|
||
val processedResourcesDir = buildDir.resolve("processedResources") | ||
|
||
fun registerCopyJvmBinaryTask(target: String, jniTarget: String, include: String = "*.so"): TaskProvider<Copy> = | ||
tasks.register<Copy>("copy-${target}") { | ||
group = "uniffi" | ||
from(projectDir.resolve("../../../target/${target}/release")) | ||
include(include) | ||
into(processedResourcesDir.resolve(jniTarget)) | ||
} | ||
|
||
val copyBinariesTasks = listOf( | ||
registerCopyJvmBinaryTask("aarch64-linux-android", "arm64-v8a"), | ||
registerCopyJvmBinaryTask("armv7-linux-androideabi", "armeabi-v7a"), | ||
registerCopyJvmBinaryTask("x86_64-linux-android", "x86_64") | ||
) | ||
|
||
project.afterEvaluate { | ||
tasks.getByName("mergeReleaseJniLibFolders") { dependsOn(copyBinariesTasks) } | ||
tasks.getByName("mergeDebugJniLibFolders") { dependsOn(copyBinariesTasks) } | ||
} | ||
|
||
tasks.withType<ProcessResources> { | ||
dependsOn(copyBinariesTasks) | ||
} | ||
|
||
android.sourceSets.getByName("main").apply { | ||
jniLibs.srcDir(processedResourcesDir) | ||
} | ||
|
||
// Allows skipping signing jars published to 'MavenLocal' repository | ||
tasks.withType<Sign>().configureEach { | ||
if (System.getenv("CI") == null) { // i.e. not in Github Action runner | ||
enabled = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
POM_ARTIFACT_ID=core-crypto-uniffi-android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
plugins { | ||
kotlin("jvm") | ||
id("java-library") | ||
id("com.vanniktech.maven.publish") | ||
} | ||
|
||
dependencies { | ||
implementation(platform(kotlin("bom"))) | ||
implementation(platform(libs.coroutines.bom)) | ||
implementation(kotlin("stdlib-jdk7")) | ||
implementation(libs.jna) | ||
implementation(libs.coroutines.core) | ||
testImplementation(platform("org.junit:junit-bom:5.10.0")) | ||
testImplementation("org.junit.jupiter:junit-jupiter") | ||
} | ||
|
||
val processedResourcesDir = buildDir.resolve("processedResources") | ||
|
||
fun registerCopyJvmBinaryTask(target: String, jniTarget: String, include: String = "*.so"): TaskProvider<Copy> = | ||
tasks.register<Copy>("copy-${target}") { | ||
group = "uniffi" | ||
from(projectDir.resolve("../../../target/${target}/release")) | ||
include(include) | ||
into(processedResourcesDir.resolve(jniTarget)) | ||
} | ||
|
||
val copyBinariesTasks = listOf( | ||
registerCopyJvmBinaryTask("x86_64-unknown-linux-gnu", "linux-x86-64"), | ||
registerCopyJvmBinaryTask("aarch64-apple-darwin", "darwin-aarch64", "*.dylib"), | ||
registerCopyJvmBinaryTask("x86_64-apple-darwin", "darwin-x86-64", "*.dylib"), | ||
) | ||
|
||
tasks.withType<ProcessResources> { dependsOn(copyBinariesTasks) } | ||
|
||
tasks.withType<Test> { dependsOn(copyBinariesTasks) } | ||
|
||
sourceSets { main { resources { srcDir(processedResourcesDir) } } } | ||
|
||
// Allows skipping signing jars published to 'MavenLocal' repository | ||
project.afterEvaluate { | ||
tasks.named("signMavenPublication").configure { | ||
if (System.getenv("CI") == null) { // i.e. not in Github Action runner | ||
enabled = false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
POM_ARTIFACT_ID=core-crypto-uniffi-jvm |