Merge pull request #63 from nicbus/nicbus/armv7

Add armeabi-v7a support
This commit is contained in:
thunderbiscuit 2022-06-15 16:52:20 -03:00 committed by GitHub
commit 29f09e7cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 1 deletions

View File

@ -33,7 +33,7 @@ jobs:
java-version: 11
- name: Install rust android targets
run: rustup target add x86_64-linux-android aarch64-linux-android
run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi
- name: Install uniffi-bindgen
run: cargo install uniffi_bindgen --version 0.16.0

View File

@ -68,6 +68,36 @@ val buildAndroidX86_64Binary by tasks.register<Exec>("buildAndroidX86_64Binary")
}
}
// armeabi-v7a version of the library for older 32-bit Android hardware
val buildAndroidArmv7Binary by tasks.register<Exec>("buildAndroidArmv7Binary") {
workingDir("${project.projectDir}/../bdk-ffi")
val cargoArgs: MutableList<String> = mutableListOf("build", "--release", "--target", "armv7-linux-androideabi")
executable("cargo")
args(cargoArgs)
// if ANDROID_NDK_ROOT is not set then set it to github actions default
if (System.getenv("ANDROID_NDK_ROOT") == null) {
environment(
Pair("ANDROID_NDK_ROOT", "${System.getenv("ANDROID_SDK_ROOT")}/ndk-bundle")
)
}
environment(
// add build toolchain to PATH
Pair("PATH", "${System.getenv("PATH")}:${System.getenv("ANDROID_NDK_ROOT")}/toolchains/llvm/prebuilt/$llvmArchPath/bin"),
Pair("CFLAGS", "-D__ANDROID_API__=21"),
Pair("CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER", "armv7a-linux-androideabi21-clang"),
Pair("CC", "armv7a-linux-androideabi21-clang")
)
doLast {
println("Native library for bdk-android on armv7 built successfully")
}
}
// move the native libs build by cargo from bdk-ffi/target/<architecture>/release/
// to their place in the bdk-android library
// the task only copies the available binaries built using the buildAndroid<architecture>Binary tasks
@ -85,6 +115,10 @@ val moveNativeAndroidLibs by tasks.register<Copy>("moveNativeAndroidLibs") {
from("${project.projectDir}/../bdk-ffi/target/x86_64-linux-android/release/libbdkffi.so")
}
into("armeabi-v7a") {
from("${project.projectDir}/../bdk-ffi/target/armv7-linux-androideabi/release/libbdkffi.so")
}
doLast {
println("Native binaries for Android moved to ./android/src/main/jniLibs/")
}
@ -112,6 +146,7 @@ tasks.register("buildAndroidLib") {
dependsOn(
buildAndroidAarch64Binary,
buildAndroidX86_64Binary,
buildAndroidArmv7Binary,
moveNativeAndroidLibs,
generateAndroidBindings
)