2021-11-22 14:17:03 -08:00
|
|
|
#!/usr/bin/env bash
|
2021-11-23 21:46:11 -08:00
|
|
|
set -euo pipefail
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
## confirm bdk-ffi rust lib builds
|
|
|
|
pushd bdk-ffi
|
|
|
|
echo "Confirm bdk-ffi rust lib builds"
|
2021-11-22 14:17:03 -08:00
|
|
|
cargo build --release
|
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
## build bdk-ffi rust libs for apple targets
|
|
|
|
echo "Build bdk-ffi libs for apple targets"
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 21:46:11 -08:00
|
|
|
TARGET_TRIPLES=("x86_64-apple-darwin" "x86_64-apple-ios" "aarch64-apple-ios")
|
|
|
|
for TARGET in ${TARGET_TRIPLES[@]}; do
|
2021-11-22 14:17:03 -08:00
|
|
|
echo "Build bdk-ffi lib for target $TARGET"
|
|
|
|
cargo build --release --target $TARGET
|
|
|
|
done
|
2021-11-23 21:46:11 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
echo "Generate bdk-ffi swift bindings"
|
|
|
|
uniffi-bindgen generate src/bdk.udl --no-format --out-dir ../Sources/BitcoinDevKit --language swift
|
2021-11-22 14:17:03 -08:00
|
|
|
popd
|
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# rename bdk.swift bindings to BitcoinDevKit.swift
|
|
|
|
mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
|
|
|
|
|
|
|
|
# copy bdkFFI.h to bdkFFI.xcframework platforms
|
|
|
|
PLATFORMS=("macos-x86_64" "ios-arm64_x86_64-simulator" "ios-arm64")
|
|
|
|
for PLATFORM in ${PLATFORMS[@]}; do
|
|
|
|
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/$PLATFORM/bdkFFI.framework/Headers
|
|
|
|
done
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# remove unneed .h and .modulemap files
|
|
|
|
rm Sources/BitcoinDevKit/bdkFFI.h
|
|
|
|
rm Sources/BitcoinDevkit/bdkFFI.modulemap
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# add bdkFFI libs to bdkFFI.xcframework
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# macos-x86_64 platform
|
|
|
|
cp bdk-ffi/target/x86_64-apple-darwin/release/libbdkffi.a bdkFFI.xcframework/macos-x86_64/bdkFFI.framework/bdkFFI
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# ios-arm64 platform
|
|
|
|
cp bdk-ffi/target/aarch64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# ios-arm64_x86_64-simulator, currently x86_64 only (need to make fat binary to add M1)
|
|
|
|
cp bdk-ffi/target/x86_64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
|
2021-11-22 14:17:03 -08:00
|
|
|
|
|
|
|
# TODO add license info
|
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# remove any existing bdkFFI.xcframework.zip
|
|
|
|
rm bdkFFI.xcframework.zip
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# zip bdkFFI.xcframework directory into a bundle for distribution
|
|
|
|
zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
|
2021-11-22 14:17:03 -08:00
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# compute bdkFFI.xcframework.zip checksum
|
|
|
|
echo checksum:
|
2021-11-22 14:17:03 -08:00
|
|
|
swift package compute-checksum bdkFFI.xcframework.zip
|
|
|
|
|
2021-11-23 22:46:38 -08:00
|
|
|
# TODO update Package.swift with checksum
|
|
|
|
# TODO upload zip to github release
|