Skip to content

Commit

Permalink
temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderbiscuit committed Sep 27, 2024
1 parent a6c3f63 commit 9e7e97f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 75 deletions.
16 changes: 1 addition & 15 deletions bdk-android/lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ android {

defaultConfig {
minSdk = 24
targetSdk = 34
// targetSdk = 34
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
Expand Down Expand Up @@ -103,15 +103,6 @@ afterEvaluate {
}
}
}

// This is required because we must ensure the moveNativeAndroidLibs task is executed after
// the mergeReleaseJniLibFolders (hard requirement introduced by our upgrade to Gradle 8.7)
tasks.named("mergeReleaseJniLibFolders") {
dependsOn(":lib:moveNativeAndroidLibs")
}
tasks.named("mergeDebugJniLibFolders") {
dependsOn(":lib:moveNativeAndroidLibs")
}
}

signing {
Expand All @@ -125,8 +116,3 @@ signing {
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications)
}

// This task dependency ensures that we build the bindings binaries before running the tests
tasks.withType<KotlinCompile> {
dependsOn("buildAndroidLib")
}
52 changes: 22 additions & 30 deletions bdk-android/scripts/build-linux-x86_64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,35 @@ if [ -z "$ANDROID_NDK_ROOT" ]; then
exit 1
fi

PATH="$PATH:$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin"
PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH"
CFLAGS="-D__ANDROID_MIN_SDK_VERSION__=24"
AR="llvm-ar"
LIB_NAME="libbdkffi.dylib"

# # Move to the Rust library directory
cd ../bdk-ffi/ || exit

# Build the Rust libraries
rustup default 1.77.1

LIB_NAME="libbdkffi.so"
COMPILATION_TARGET_ARM64_V8A="aarch64-linux-android"
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android24-clang"
RESOURCE_DIR_ARM64_V8A="arm64-v8a"
CC="aarch64-linux-android24-clang"
rustup target add $COMPILATION_TARGET_ARM64_V8A
cargo build --profile release-smaller --target $COMPILATION_TARGET_ARM64_V8A

COMPILATION_TARGET_X86_64="x86_64-linux-android"
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="x86_64-linux-android24-clang"
RESOURCE_DIR_X86_64="x86_64"
CC="x86_64-linux-android24-clang"
rustup target add $COMPILATION_TARGET_X86_64
cargo build --profile release-smaller --target $COMPILATION_TARGET_X86_64

COMPILATION_TARGET_ARMEABI_V7A="armv7-linux-androideabi"
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="armv7a-linux-androideabi24-clang"
RESOURCE_DIR_ARM64_V8A="arm64-v8a"
RESOURCE_DIR_X86_64="x86_64"
RESOURCE_DIR_ARMEABI_V7A="armeabi-v7a"
CC="armv7a-linux-androideabi24-clang"
rustup target add $COMPILATION_TARGET_ARMEABI_V7A
cargo build --profile release-smaller --target $COMPILATION_TARGET_ARMEABI_V7A

# Move to the Rust library directory
cd ../bdk-ffi/ || exit
rustup default 1.77.1
rustup target add $COMPILATION_TARGET_ARM64_V8A $COMPILATION_TARGET_ARMEABI_V7A $COMPILATION_TARGET_X86_64

# Build the binaries
# The CC and CARGO_TARGET_<TARGET>_LINUX_ANDROID_LINKER environment variables must be declared on the same line as the cargo build command
CC="aarch64-linux-android24-clang" CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android24-clang" cargo build --profile release-smaller --target $COMPILATION_TARGET_ARM64_V8A
CC="x86_64-linux-android24-clang" CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="x86_64-linux-android24-clang" cargo build --profile release-smaller --target $COMPILATION_TARGET_X86_64
CC="armv7a-linux-androideabi24-clang" CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="armv7a-linux-androideabi24-clang" cargo build --profile release-smaller --target $COMPILATION_TARGET_ARMEABI_V7A

# Copy the binaries to their respective resource directories
cp ./$TARGET_DIR/$LIB_NAME ../bdk-jvm/lib/src/main/$RESOURCE_DIR_ARM64_V8A/
cp ./$TARGET_DIR/$LIB_NAME ../bdk-jvm/lib/src/main/$RESOURCE_DIR_X86_64/
cp ./$TARGET_DIR/$LIB_NAME ../bdk-jvm/lib/src/main/$RESOURCE_DIR_ARMEABI_V7A/
mkdir -p ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARM64_V8A/
mkdir -p ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARMEABI_V7A/
mkdir -p ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_X86_64/
cp ./target/$COMPILATION_TARGET_ARM64_V8A/release-smaller/$LIB_NAME ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARM64_V8A/
cp ./target/$COMPILATION_TARGET_ARMEABI_V7A/release-smaller/$LIB_NAME ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARMEABI_V7A/
cp ./target/$COMPILATION_TARGET_X86_64/release-smaller/$LIB_NAME ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_X86_64/

# Generate Kotlin bindings using uniffi-bindgen
TARGET_DIR="target/$COMPILATION_TARGET_ARM64_V8A/release-smaller"
cargo run --bin uniffi-bindgen generate --library ./$TARGET_DIR/$LIB_NAME --language kotlin --out-dir ../bdk-jvm/lib/src/main/kotlin/ --no-format
cargo run --bin uniffi-bindgen generate --library ./target/$COMPILATION_TARGET_ARM64_V8A/release-smaller/$LIB_NAME --language kotlin --out-dir ../bdk-android/lib/src/main/kotlin/ --no-format
52 changes: 22 additions & 30 deletions bdk-android/scripts/build-macos-aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,35 @@ if [ -z "$ANDROID_NDK_ROOT" ]; then
exit 1
fi

PATH="$PATH:$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/darwin-x86_64/bin"
PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/darwin-x86_64/bin:$PATH"
CFLAGS="-D__ANDROID_MIN_SDK_VERSION__=24"
AR="llvm-ar"
LIB_NAME="libbdkffi.dylib"

# # Move to the Rust library directory
cd ../bdk-ffi/ || exit

# Build the Rust libraries
rustup default 1.77.1

LIB_NAME="libbdkffi.so"
COMPILATION_TARGET_ARM64_V8A="aarch64-linux-android"
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android24-clang"
RESOURCE_DIR_ARM64_V8A="arm64-v8a"
CC="aarch64-linux-android24-clang"
rustup target add $COMPILATION_TARGET_ARM64_V8A
cargo build --profile release-smaller --target $COMPILATION_TARGET_ARM64_V8A

COMPILATION_TARGET_X86_64="x86_64-linux-android"
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="x86_64-linux-android24-clang"
RESOURCE_DIR_X86_64="x86_64"
CC="x86_64-linux-android24-clang"
rustup target add $COMPILATION_TARGET_X86_64
cargo build --profile release-smaller --target $COMPILATION_TARGET_X86_64

COMPILATION_TARGET_ARMEABI_V7A="armv7-linux-androideabi"
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="armv7a-linux-androideabi24-clang"
RESOURCE_DIR_ARM64_V8A="arm64-v8a"
RESOURCE_DIR_X86_64="x86_64"
RESOURCE_DIR_ARMEABI_V7A="armeabi-v7a"
CC="armv7a-linux-androideabi24-clang"
rustup target add $COMPILATION_TARGET_ARMEABI_V7A
cargo build --profile release-smaller --target $COMPILATION_TARGET_ARMEABI_V7A

# Move to the Rust library directory
cd ../bdk-ffi/ || exit
rustup default 1.77.1
rustup target add $COMPILATION_TARGET_ARM64_V8A $COMPILATION_TARGET_ARMEABI_V7A $COMPILATION_TARGET_X86_64

# Build the binaries
# The CC and CARGO_TARGET_<TARGET>_LINUX_ANDROID_LINKER environment variables must be declared on the same line as the cargo build command
CC="aarch64-linux-android24-clang" CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android24-clang" cargo build --profile release-smaller --target $COMPILATION_TARGET_ARM64_V8A
CC="x86_64-linux-android24-clang" CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="x86_64-linux-android24-clang" cargo build --profile release-smaller --target $COMPILATION_TARGET_X86_64
CC="armv7a-linux-androideabi24-clang" CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="armv7a-linux-androideabi24-clang" cargo build --profile release-smaller --target $COMPILATION_TARGET_ARMEABI_V7A

# Copy the binaries to their respective resource directories
cp ./$TARGET_DIR/$LIB_NAME ../bdk-jvm/lib/src/main/$RESOURCE_DIR_ARM64_V8A/
cp ./$TARGET_DIR/$LIB_NAME ../bdk-jvm/lib/src/main/$RESOURCE_DIR_X86_64/
cp ./$TARGET_DIR/$LIB_NAME ../bdk-jvm/lib/src/main/$RESOURCE_DIR_ARMEABI_V7A/
mkdir -p ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARM64_V8A/
mkdir -p ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARMEABI_V7A/
mkdir -p ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_X86_64/
cp ./target/$COMPILATION_TARGET_ARM64_V8A/release-smaller/$LIB_NAME ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARM64_V8A/
cp ./target/$COMPILATION_TARGET_ARMEABI_V7A/release-smaller/$LIB_NAME ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_ARMEABI_V7A/
cp ./target/$COMPILATION_TARGET_X86_64/release-smaller/$LIB_NAME ../bdk-android/lib/src/main/jniLibs/$RESOURCE_DIR_X86_64/

# Generate Kotlin bindings using uniffi-bindgen
TARGET_DIR="target/$COMPILATION_TARGET_ARM64_V8A/release-smaller"
cargo run --bin uniffi-bindgen generate --library ./$TARGET_DIR/$LIB_NAME --language kotlin --out-dir ../bdk-jvm/lib/src/main/kotlin/ --no-format
cargo run --bin uniffi-bindgen generate --library ./target/$COMPILATION_TARGET_ARM64_V8A/release-smaller/$LIB_NAME --language kotlin --out-dir ../bdk-android/lib/src/main/kotlin/ --no-format

0 comments on commit 9e7e97f

Please sign in to comment.