diff --git a/bdk-android/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiAndroidPlugin.kt b/bdk-android/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiAndroidPlugin.kt index b43d2633..07b7a288 100644 --- a/bdk-android/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiAndroidPlugin.kt +++ b/bdk-android/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiAndroidPlugin.kt @@ -123,14 +123,14 @@ internal class UniFfiAndroidPlugin : Plugin { val generateAndroidBindings by tasks.register("generateAndroidBindings") { dependsOn(moveNativeAndroidLibs) - // val libraryPath = "${project.projectDir}/../../bdk-ffi/target/aarch64-linux-android/release-smaller/libbdkffi.so" - // workingDir("${project.projectDir}/../../bdk-ffi") - // val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "--library", libraryPath, "--language", "kotlin", "--out-dir", "../bdk-android/lib/src/main/kotlin", "--no-format") + val libraryPath = "${project.projectDir}/../../bdk-ffi/target/aarch64-linux-android/release-smaller/libbdkffi.so" + workingDir("${project.projectDir}/../../bdk-ffi") + val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "--library", libraryPath, "--language", "kotlin", "--out-dir", "../bdk-android/lib/src/main/kotlin", "--no-format") // The code above worked for uniffi 0.24.3 using the --library flag // The code below works for uniffi 0.23.0 - workingDir("${project.projectDir}/../../bdk-ffi") - val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "src/bdk.udl", "--language", "kotlin", "--config", "uniffi-android.toml", "--out-dir", "../bdk-android/lib/src/main/kotlin", "--no-format") + // workingDir("${project.projectDir}/../../bdk-ffi") + // val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "src/bdk.udl", "--language", "kotlin", "--config", "uniffi-android.toml", "--out-dir", "../bdk-android/lib/src/main/kotlin", "--no-format") executable("cargo") args(cargoArgs) diff --git a/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt b/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt index 9dd09e92..415ccc19 100644 --- a/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt +++ b/bdk-jvm/plugins/src/main/kotlin/org/bitcoindevkit/plugins/UniFfiJvmPlugin.kt @@ -112,20 +112,20 @@ internal class UniFfiJvmPlugin : Plugin { // TODO 2: Is the Windows name the correct one? // TODO 3: This will not work on mac Intel (x86_64 architecture) - // val libraryPath = when (operatingSystem) { - // OS.LINUX -> "./target/x86_64-unknown-linux-gnu/release-smaller/libbdkffi.so" - // OS.MAC -> "./target/aarch64-apple-darwin/release-smaller/libbdkffi.dylib" - // OS.WINDOWS -> "./target/x86_64-pc-windows-msvc/release-smaller/bdkffi.dll" - // else -> throw Exception("Unsupported OS") - // } + val libraryPath = when (operatingSystem) { + OS.LINUX -> "./target/x86_64-unknown-linux-gnu/release-smaller/libbdkffi.so" + OS.MAC -> "./target/aarch64-apple-darwin/release-smaller/libbdkffi.dylib" + OS.WINDOWS -> "./target/x86_64-pc-windows-msvc/release-smaller/bdkffi.dll" + else -> throw Exception("Unsupported OS") + } - // workingDir("${project.projectDir}/../../bdk-ffi/") - // val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "--library", libraryPath, "--language", "kotlin", "--out-dir", "../bdk-jvm/lib/src/main/kotlin/", "--no-format") + workingDir("${project.projectDir}/../../bdk-ffi/") + val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "--library", libraryPath, "--language", "kotlin", "--out-dir", "../bdk-jvm/lib/src/main/kotlin/", "--no-format") // The code above was for the migration to uniffi 0.24.3 using the --library flag // The code below works with uniffi 0.23.0 - workingDir("${project.projectDir}/../../bdk-ffi/") - val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "src/bdk.udl", "--language", "kotlin", "--out-dir", "../bdk-jvm/lib/src/main/kotlin", "--no-format") + // workingDir("${project.projectDir}/../../bdk-ffi/") + // val cargoArgs: List = listOf("run", "--bin", "uniffi-bindgen", "generate", "src/bdk.udl", "--language", "kotlin", "--out-dir", "../bdk-jvm/lib/src/main/kotlin", "--no-format") executable("cargo") args(cargoArgs) diff --git a/bdk-python/scripts/generate-linux.sh b/bdk-python/scripts/generate-linux.sh index 5382e494..c8d5e713 100644 --- a/bdk-python/scripts/generate-linux.sh +++ b/bdk-python/scripts/generate-linux.sh @@ -4,14 +4,15 @@ set -euo pipefail ${PYBIN}/python --version ${PYBIN}/pip install -r requirements.txt -echo "Generating bdk.py..." cd ../bdk-ffi/ rustup default 1.77.1 -cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format echo "Generating native binaries..." cargo build --profile release-smaller +echo "Generating bdk.py..." +cargo run --bin uniffi-bindgen generate --library ./target/release-smaller/libbdkffi.so --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + echo "Copying linux libbdkffi.so..." cp ./target/release-smaller/libbdkffi.so ../bdk-python/src/bdkpython/libbdkffi.so diff --git a/bdk-python/scripts/generate-macos-arm64.sh b/bdk-python/scripts/generate-macos-arm64.sh index 1d5ab4e4..38a608c0 100644 --- a/bdk-python/scripts/generate-macos-arm64.sh +++ b/bdk-python/scripts/generate-macos-arm64.sh @@ -4,15 +4,16 @@ set -euo pipefail python3 --version pip install -r requirements.txt -echo "Generating bdk.py..." cd ../bdk-ffi/ rustup default 1.77.1 -cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format +rustup target add aarch64-apple-darwin echo "Generating native binaries..." -rustup target add aarch64-apple-darwin cargo build --profile release-smaller --target aarch64-apple-darwin +echo "Generating bdk.py..." +cargo run --bin uniffi-bindgen generate --library ./target/aarch64-apple-darwin/release-smaller/libbdkffi.dylib --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + echo "Copying libraries libbdkffi.dylib..." cp ./target/aarch64-apple-darwin/release-smaller/libbdkffi.dylib ../bdk-python/src/bdkpython/libbdkffi.dylib diff --git a/bdk-python/scripts/generate-macos-x86_64.sh b/bdk-python/scripts/generate-macos-x86_64.sh index b8faafd6..79d3896e 100644 --- a/bdk-python/scripts/generate-macos-x86_64.sh +++ b/bdk-python/scripts/generate-macos-x86_64.sh @@ -4,15 +4,16 @@ set -euo pipefail python3 --version pip install -r requirements.txt -echo "Generating bdk.py..." cd ../bdk-ffi/ rustup default 1.77.1 -cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format +rustup target add x86_64-apple-darwin echo "Generating native binaries..." -rustup target add x86_64-apple-darwin cargo build --profile release-smaller --target x86_64-apple-darwin +echo "Generating bdk.py..." +cargo run --bin uniffi-bindgen generate --library ./target/x86_64-apple-darwin/release-smaller/libbdkffi.dylib --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + echo "Copying libraries libbdkffi.dylib..." cp ./target/x86_64-apple-darwin/release-smaller/libbdkffi.dylib ../bdk-python/src/bdkpython/libbdkffi.dylib diff --git a/bdk-python/scripts/generate-windows.sh b/bdk-python/scripts/generate-windows.sh index a86a77ab..2f936b33 100644 --- a/bdk-python/scripts/generate-windows.sh +++ b/bdk-python/scripts/generate-windows.sh @@ -4,15 +4,16 @@ set -euo pipefail python3 --version pip install -r requirements.txt -echo "Generating bdk.py..." cd ../bdk-ffi/ rustup default 1.77.1 -cargo run --bin uniffi-bindgen generate src/bdk.udl --language python --out-dir ../bdk-python/src/bdkpython/ --no-format +rustup target add x86_64-pc-windows-msvc echo "Generating native binaries..." -rustup target add x86_64-pc-windows-msvc cargo build --profile release-smaller --target x86_64-pc-windows-msvc +echo "Generating bdk.py..." +cargo run --bin uniffi-bindgen generate --library ./target/x86_64-pc-windows-msvc/release-smaller/bdkffi.dll --language python --out-dir ../bdk-python/src/bdkpython/ --no-format + echo "Copying libraries bdkffi.dll..." cp ./target/x86_64-pc-windows-msvc/release-smaller/bdkffi.dll ../bdk-python/src/bdkpython/bdkffi.dll diff --git a/bdk-swift/build-local-swift.sh b/bdk-swift/build-local-swift.sh index 1fad9bba..44b530b2 100755 --- a/bdk-swift/build-local-swift.sh +++ b/bdk-swift/build-local-swift.sh @@ -12,7 +12,6 @@ rustup target add aarch64-apple-darwin # mac M1 rustup target add x86_64-apple-darwin # mac x86_64 cd ../bdk-ffi/ || exit -cargo run --bin uniffi-bindgen generate src/bdk.udl --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit --no-format cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-darwin cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-darwin @@ -20,6 +19,8 @@ cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-io cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios cargo build --package bdk-ffi --profile release-smaller --target aarch64-apple-ios-sim +cargo run --bin uniffi-bindgen generate --library ./target/aarch64-apple-ios/release-smaller/libbdkffi.dylib --language swift --out-dir ../bdk-swift/Sources/BitcoinDevKit --no-format + mkdir -p target/lipo-ios-sim/release-smaller lipo target/aarch64-apple-ios-sim/release-smaller/libbdkffi.a target/x86_64-apple-ios/release-smaller/libbdkffi.a -create -output target/lipo-ios-sim/release-smaller/libbdkffi.a mkdir -p target/lipo-macos/release-smaller