Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: kotlin wrapper #150

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
15 changes: 15 additions & 0 deletions wrappers/kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local.properties
build
.gradle
.DS_STORE
.idea/
.gradle/
*.iml
*.hprof
.cxx/

*.db*
*.db
*.db-shm
*.db-wal
target
24 changes: 24 additions & 0 deletions wrappers/kotlin/build-targets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# BUILD IOS TARGETS
rustup toolchain install 1.64.0 --target aarch64-apple-ios --profile minimal --no-self-update
cargo build --release --target aarch64-apple-ios &
rustup toolchain install 1.64.0 --target aarch64-apple-ios-sim --profile minimal --no-self-update
cargo build --release --target aarch64-apple-ios-sim &
rustup toolchain install 1.64.0 --target x86_64-apple-ios --profile minimal --no-self-update
cargo build --release --target x86_64-apple-ios &

# BUILD ANDROID TARGETS

#cargo install --bins --git https://github.com/rust-embedded/cross --tag v0.2.4 cross
cargo install cross --git https://github.com/cross-rs/cross

rustup toolchain install 1.64.0 --target aarch64-linux-android --profile minimal --no-self-update
cross build --release --target aarch64-linux-android &
rustup toolchain install 1.64.0 --target armv7-linux-androideabi --profile minimal --no-self-update
cross build --release --target armv7-linux-androideabi &
rustup toolchain install 1.64.0 --target i686-linux-android --profile minimal --no-self-update
cross build --release --target i686-linux-android &
rustup toolchain install 1.64.0 --target x86_64-linux-android --profile minimal --no-self-update
cross build --release --target x86_64-linux-android &

# BUILD MAC OS TARGETS
../../build-universal.sh
142 changes: 142 additions & 0 deletions wrappers/kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import java.util.*

plugins {
kotlin("multiplatform") version "1.8.21"
kotlin("plugin.serialization") version "1.8.21"
id("maven-publish")
}

repositories {
mavenCentral()
}

// Stub secrets to let the project sync and build without the publication values set up
ext["githubUsername"] = null
ext["githubToken"] = null
ext["askarVersion"] = "0.2.9-dev.3"
ext["wrapperVersion"] = "3.4"

val secretPropsFile = project.rootProject.file("local.properties")
if(secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach{ (name, value) ->
ext[name.toString()] = value
}
} else {
ext["githubUsername"] = System.getenv("GITHUB_USERNAME")
ext["githubToken"] = System.getenv("GITHUB_TOKEN")
}

fun getExtraString(name: String) = ext[name]?.toString()

group = "org.hyperledger.aries-askar"
version = "${getExtraString("askarVersion")}-wrapper.${getExtraString("wrapperVersion")}"

publishing{
repositories{
maven{
name = "github"
setUrl("https://maven.pkg.github.com/indicio-tech/aries-askar")
credentials {
username = getExtraString("githubUsername")
password = getExtraString("githubToken")
}
}
}

publications.withType<MavenPublication> {
pom {
name.set("Aries Askar Kotlin")
description.set("Kotlin MPP wrapper around aries-askar")
url.set("https://github.com/indicio-tech/aries-askar")

scm{
url.set("https://github.com/indicio-tech/aries-askar")
}
}
}
}

private enum class PlatformType {
APPLE,
ANDROID
}

kotlin {

fun addLibs(libDirectory: String, target: KotlinNativeTarget) {
target.compilations.getByName("main") {
val aries_askar by cinterops.creating {
this.includeDirs("libraries/headers/")
packageName("aries_askar")
}
}

target.binaries.all {
linkerOpts("-L${libDirectory}", "-laries_askar")
linkerOpts("-Wl,-framework,Security")
}

}

macosX64{
val libDirectory = "${projectDir}/../../target/x86_64-apple-darwin/release"
addLibs(libDirectory, this)
}

macosArm64{
val libDirectory = "${projectDir}/../../target/aarch64-apple-darwin/release"
addLibs(libDirectory, this)
}

iosX64 {
val libDirectory = "${projectDir}/../../target/x86_64-apple-ios/release"
addLibs(libDirectory, this)
}

iosSimulatorArm64 {
val libDirectory = "${projectDir}/../../target/aarch64-apple-ios-sim/release"
addLibs(libDirectory, this)
}

iosArm64 {
val libDirectory = "${projectDir}/../../target/aarch64-apple-ios/release"
addLibs(libDirectory, this)
}

androidNativeArm64(){
val libDirectory = "${projectDir}/../../target/aarch64-linux-android/release"
addLibs(libDirectory, this)
}

androidNativeX64(){
val libDirectory = "${projectDir}/../../target/i686-linux-android/release"
addLibs(libDirectory, this)
}

androidNativeX86(){
val libDirectory = "${projectDir}/../../target/x86_64-linux-android/release"
addLibs(libDirectory, this)
}

androidNativeArm32(){
val libDirectory = "${projectDir}/../../target/armv7-linux-androideabi/release"
addLibs(libDirectory, this)
}

sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.0-RC")
}
}
val commonTest by getting {
this.dependsOn(commonMain)
}
}
}
5 changes: 5 additions & 0 deletions wrappers/kotlin/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kotlin.code.style=official
kotlin.native.cacheKind.macosX64=none
kotlin.native.cacheKind.iosX64=none
kotlin.mpp.enableCInteropCommonization=true
kotlin.native.cacheKind.androidNativeArm32=none
Binary file added wrappers/kotlin/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions wrappers/kotlin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading