Skip to content

Commit

Permalink
Fix Android build in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Apr 19, 2023
1 parent b8b60dd commit 2a51807
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/test-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ env:

jobs:
build:
runs-on: ubuntu-22.04
# The build cannot be done on the ubuntu-22.04 image, see issue #346
runs-on: ubuntu-20.04
steps:
- name: "Install Android NDK 21.4.7075529"
run: |
Expand Down Expand Up @@ -48,6 +49,11 @@ jobs:
- name: "Install Rust Android targets"
run: rustup target add x86_64-linux-android aarch64-linux-android armv7-linux-androideabi

- name: "Build Android library"
run: |
cd bdk-android
./gradlew buildAndroidLib
# There are currently no unit tests for bdk-android and the integration tests require the macOS image
# which is not working with the older NDK version we are using, so for now we just make sure that the library builds.
# - name: "Run Android unit tests"
Expand Down
2 changes: 2 additions & 0 deletions bdk-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ For some older versions of macOS, Android Studio will recommend users install th
[`bdk`]: https://github.com/bitcoindevkit/bdk
[`bdk-ffi`]: https://github.com/bitcoindevkit/bdk-ffi
Temporary line: needed to run CI
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ internal class UniFfiAndroidPlugin : Plugin<Project> {
val buildAndroidAarch64Binary by tasks.register<Exec>("buildAndroidAarch64Binary") {

workingDir("${projectDir}/../../bdk-ffi")
val cargoArgs: List<String> = listOf("build", "--profile", "release-smaller", "--target", "aarch64-linux-android")
val cargoArgs: MutableList<String> =
mutableListOf("build", "--profile", "release-smaller", "--target", "aarch64-linux-android")

executable("cargo")
args(cargoArgs)
Expand All @@ -35,9 +36,10 @@ internal class UniFfiAndroidPlugin : Plugin<Project> {

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_MIN_SDK_VERSION__=21"),
Pair("AR", "llvm-ar"),
Pair("PATH",
"${System.getenv("PATH")}:${System.getenv("ANDROID_NDK_ROOT")}/toolchains/llvm/prebuilt/$llvmArchPath/bin"),

Pair("CFLAGS", "-D__ANDROID_API__=21"),
Pair("CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER", "aarch64-linux-android21-clang"),
Pair("CC", "aarch64-linux-android21-clang")
)
Expand All @@ -51,7 +53,8 @@ internal class UniFfiAndroidPlugin : Plugin<Project> {
val buildAndroidX86_64Binary by tasks.register<Exec>("buildAndroidX86_64Binary") {

workingDir("${project.projectDir}/../../bdk-ffi")
val cargoArgs: List<String> = listOf("build", "--profile", "release-smaller", "--target", "x86_64-linux-android")
val cargoArgs: MutableList<String> =
mutableListOf("build", "--profile", "release-smaller", "--target", "x86_64-linux-android")

executable("cargo")
args(cargoArgs)
Expand All @@ -65,9 +68,10 @@ internal class UniFfiAndroidPlugin : Plugin<Project> {

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_MIN_SDK_VERSION__=21"),
Pair("AR", "llvm-ar"),
Pair("PATH",
"${System.getenv("PATH")}:${System.getenv("ANDROID_NDK_ROOT")}/toolchains/llvm/prebuilt/$llvmArchPath/bin"),

Pair("CFLAGS", "-D__ANDROID_API__=21"),
Pair("CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER", "x86_64-linux-android21-clang"),
Pair("CC", "x86_64-linux-android21-clang")
)
Expand All @@ -81,7 +85,8 @@ internal class UniFfiAndroidPlugin : Plugin<Project> {
val buildAndroidArmv7Binary by tasks.register<Exec>("buildAndroidArmv7Binary") {

workingDir("${project.projectDir}/../../bdk-ffi")
val cargoArgs: List<String> = listOf("build", "--profile", "release-smaller", "--target", "armv7-linux-androideabi")
val cargoArgs: MutableList<String> =
mutableListOf("build", "--profile", "release-smaller", "--target", "armv7-linux-androideabi")

executable("cargo")
args(cargoArgs)
Expand All @@ -95,10 +100,12 @@ internal class UniFfiAndroidPlugin : Plugin<Project> {

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_MIN_SDK_VERSION__=21"),
Pair("AR", "llvm-ar"),
Pair("CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER", "armv7a-linux-androideabi21-clang"),
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")
)

Expand Down

0 comments on commit 2a51807

Please sign in to comment.