Skip to content

Commit e09beb6

Browse files
committed
fix: android bindings
1 parent 1c272de commit e09beb6

File tree

7 files changed

+142
-26
lines changed

7 files changed

+142
-26
lines changed

.github/workflows/kotlin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
4545
- name: "Build Kotlin Multiplatform bindings"
4646
run: |
47-
/usr/local/bin/task build:android
47+
/usr/local/bin/task build:kotlin
4848
4949
- name: "Build Android library"
5050
working-directory: libs/gl-sdk-android

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ metadata.json
3434
examples/javascript/node_modules
3535
examples/javascript/response.bin
3636
examples/javascript/package-lock.json
37+
38+
# IntelliJ
39+
.idea/

build/.tasks.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@ tasks:
1313
kotlin:
1414
deps:
1515
- android
16+
vars:
17+
OS_NAME:
18+
sh: uname | tr '[:upper:]' '[:lower:]'
1619
cmds:
17-
- cargo install --bin gobley-uniffi-bindgen gobley-uniffi-bindgen@0.2.0
20+
- cargo install --bin gobley-uniffi-bindgen gobley-uniffi-bindgen@0.3.7
1821
- gobley-uniffi-bindgen --config ./libs/gl-sdk/uniffi.kotlin-multiplatform.toml --library ./target/aarch64-linux-android/debug/libglsdk.a --out-dir target/release/kotlin-multiplatform
1922
- cp -a ./target/release/kotlin-multiplatform/* libs/gl-sdk-android/lib/src/
23+
- cp -a {{.ANDROID_NDK_HOME}}/toolchains/llvm/prebuilt/{{.OS_NAME}}-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so libs/gl-sdk-android/lib/src/androidMain/jniLibs/arm64-v8a/
24+
- cp -a {{.ANDROID_NDK_HOME}}/toolchains/llvm/prebuilt/{{.OS_NAME}}-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so libs/gl-sdk-android/lib/src/androidMain/jniLibs/armeabi-v7a/
25+
- cp -a {{.ANDROID_NDK_HOME}}/toolchains/llvm/prebuilt/{{.OS_NAME}}-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so libs/gl-sdk-android/lib/src/androidMain/jniLibs/x86/
26+
- cp -a {{.ANDROID_NDK_HOME}}/toolchains/llvm/prebuilt/{{.OS_NAME}}-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so libs/gl-sdk-android/lib/src/androidMain/jniLibs/x86_64/
2027

2128
swift:
2229
deps:

libs/gl-sdk-android/.gitignore

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
### Android ###
2+
# Gradle files
3+
.gradle/
4+
build/
5+
6+
# Local configuration file (sdk path, etc)
7+
local.properties
8+
9+
# Log/OS Files
10+
*.log
11+
12+
# Android Studio generated files and folders
13+
captures/
14+
.externalNativeBuild/
15+
.cxx/
16+
*.apk
17+
output.json
18+
19+
# IntelliJ
20+
*.iml
21+
.idea/
22+
misc.xml
23+
deploymentTargetDropDown.xml
24+
render.experimental.xml
25+
26+
# Keystore files
27+
*.jks
28+
*.keystore
29+
30+
# Google Services (e.g. APIs or Firebase)
31+
google-services.json
32+
33+
# Android Profiling
34+
*.hprof
35+
36+
### Android Patch ###
37+
gen-external-apklibs
38+
39+
# Replacement of .externalNativeBuild directories introduced
40+
# with Android Studio 3.5.
41+
42+
### Kotlin ###
43+
# Compiled class file
44+
*.class
45+
46+
# Log file
47+
48+
# BlueJ files
49+
*.ctxt
50+
51+
# Mobile Tools for Java (J2ME)
52+
.mtj.tmp/
53+
54+
# Package Files #
55+
*.jar
56+
*.war
57+
*.nar
58+
*.ear
59+
*.zip
60+
*.tar.gz
61+
*.rar
62+
63+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
64+
hs_err_pid*
65+
replay_pid*
66+
67+
glsdk.h
68+
glsdk.common.kt
69+
glsdk.android.kt
70+
glsdk.jvm.kt
71+
glsdk.native.kt

libs/gl-sdk-android/gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[versions]
22
annotation = "1.9.1"
3-
kotlin = "2.2.20"
3+
kotlin = "2.2.21"
44
kotlinx-serialization = "1.9.0"
55
kotlinx-coroutines = "1.10.2"
6-
android-gradle-plugin = "8.13.0"
6+
android-gradle-plugin = "8.13.2"
77
okio = "3.16.0"
88
espresso = "3.7.0"
99
jna = "5.18.1"
1010
junit = "4.13.2"
1111
junit-ext = "1.3.0"
12-
maven-publish = "0.34.0"
12+
maven-publish = "0.35.0"
1313
atomicfu = "0.29.0"
1414

1515
[libraries]

libs/gl-sdk-android/lib/build.gradle.kts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,38 @@ kotlin {
1717
compilerOptions { jvmTarget.set(JvmTarget.JVM_1_8) }
1818
}
1919

20+
/*
2021
jvm()
22+
*/
2123

22-
val xcf = XCFramework()
2324
/*
24-
listOf(
25-
iosArm64(),
26-
iosSimulatorArm64()
27-
).forEach {
28-
29-
it.binaries.framework {
30-
baseName = "glsdk"
31-
xcf.add(this)
32-
}
25+
val xcf = XCFramework()
3326
34-
val platform = when (it.targetName) {
35-
"iosSimulatorArm64" -> "ios_simulator_arm64"
36-
"iosArm64" -> "ios_arm64"
37-
else -> error("Unsupported target $name")
38-
}
27+
listOf(
28+
iosArm64(),
29+
iosSimulatorArm64()
30+
).forEach {
31+
32+
it.binaries.framework {
33+
baseName = "glsdk"
34+
xcf.add(this)
35+
}
36+
37+
val platform = when (it.targetName) {
38+
"iosSimulatorArm64" -> "ios_simulator_arm64"
39+
"iosArm64" -> "ios_arm64"
40+
else -> error("Unsupported target $name")
41+
}
3942
4043
41-
it.compilations["main"].cinterops {
42-
create("glsdkCInterop") {
43-
defFile(project.file("src/nativeInterop/cinterop/glsdk.def"))
44-
includeDirs(project.file("src/nativeInterop/cinterop/headers/glsdk/"), project.file("src/libs/$platform"))
44+
it.compilations["main"].cinterops {
45+
create("glsdkCInterop") {
46+
defFile(project.file("src/nativeInterop/cinterop/glsdk.def"))
47+
includeDirs(project.file("src/nativeInterop/cinterop/headers/glsdk/"), project.file("src/libs/$platform"))
48+
}
4549
}
4650
}
47-
}
48-
*/
51+
*/
4952
compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes")
5053

5154
sourceSets {
@@ -140,3 +143,13 @@ mavenPublishing {
140143
extensions.configure<SigningExtension> {
141144
useGpgCmd()
142145
}
146+
147+
// Do not require signing when publishing to Maven Local
148+
// Allows `./gradlew publishToMavenLocal` (or `publishToLocalMaven`) without GPG setup
149+
tasks.withType<Sign>().configureEach {
150+
onlyIf {
151+
val taskNames = gradle.startParameter.taskNames
152+
// Skip signing if the build is targeting the local Maven repository
153+
taskNames.none { it.contains("publishToMavenLocal", ignoreCase = true) || it.contains("publishToLocalMaven", ignoreCase = true) }
154+
}
155+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.blockstream.glsdk
2+
3+
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import glsdk.Signer
5+
import org.junit.Test
6+
import org.junit.runner.RunWith
7+
8+
/**
9+
* Instrumented test, which will execute on an Android device.
10+
*
11+
* See [testing documentation](http://d.android.com/tools/testing).
12+
*/
13+
@RunWith(AndroidJUnit4::class)
14+
class InstrumentedTest {
15+
16+
@Test
17+
fun test() {
18+
val mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
19+
val signer = Signer(mnemonic)
20+
signer.start()
21+
}
22+
}

0 commit comments

Comments
 (0)