-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: update scripts to build xcframework
- Loading branch information
1 parent
f680f5b
commit 6c4d3a7
Showing
16 changed files
with
85 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ bdkFFI.h | |
BitcoinDevKit.swift | ||
bdk.swift | ||
.build | ||
bdkffi.xcframework | ||
*.modulemap | ||
|
||
# Python related | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Headers/bdkFFI-umbrella.h
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Info.plist
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
bdk-swift/bdkFFI.xcframework/ios-arm64/bdkFFI.framework/Modules/module.modulemap
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
.../bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Headers/bdkFFI-umbrella.h
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
bdk-swift/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Info.plist
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...t/bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/Modules/module.modulemap
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Headers/bdkFFI-umbrella.h
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Info.plist
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
bdk-swift/bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/Modules/module.modulemap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
# This script builds local swift-bdk Swift language bindings and corresponding bdkFFI.xcframework. | ||
# The results of this script can be used for locally testing your SPM package adding a local package | ||
# to your application pointing at the bdk-swift directory. | ||
|
||
HEADERPATH="Sources/BitcoinDevKit/bdkFFI.h" | ||
MODMAPPATH="Sources/BitcoinDevKit/bdkFFI.modulemap" | ||
TARGETDIR="../target" | ||
OUTDIR="." | ||
RELDIR="release-smaller" | ||
NAME="bdkffi" | ||
STATIC_LIB_NAME="lib${NAME}.a" | ||
NEW_HEADER_DIR="../target/include" | ||
|
||
# set required rust version and install component and targets | ||
rustup default 1.77.1 | ||
rustup component add rust-src | ||
rustup target add aarch64-apple-ios # iOS arm64 | ||
rustup target add x86_64-apple-ios # iOS x86_64 | ||
rustup target add aarch64-apple-ios-sim # simulator mac M1 | ||
rustup target add aarch64-apple-darwin # mac M1 | ||
rustup target add x86_64-apple-darwin # mac x86_64 | ||
|
||
cd ../bdk-ffi/ || exit | ||
|
||
# build bdk-ffi rust lib for apple targets | ||
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 | ||
cargo build --package bdk-ffi --profile release-smaller --target x86_64-apple-ios | ||
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 | ||
|
||
# build bdk-ffi Swift bindings and put in bdk-swift Sources | ||
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 | ||
|
||
# combine bdk-ffi static libs for aarch64 and x86_64 targets via lipo tool | ||
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 | ||
lipo ../target/aarch64-apple-darwin/release-smaller/libbdkffi.a ../target/x86_64-apple-darwin/release-smaller/libbdkffi.a -create -output ../target/lipo-macos/release-smaller/libbdkffi.a | ||
|
||
cd ../bdk-swift/ || exit | ||
|
||
# move bdk-ffi static lib header files to temporary directory | ||
mkdir -p "${NEW_HEADER_DIR}" | ||
mv "${HEADERPATH}" "${NEW_HEADER_DIR}" | ||
mv "${MODMAPPATH}" "${NEW_HEADER_DIR}/module.modulemap" | ||
echo -e "\n" >> "${NEW_HEADER_DIR}/module.modulemap" | ||
|
||
# remove old xcframework directory | ||
rm -rf "${OUTDIR}/${NAME}.xcframework" | ||
|
||
# create new xcframework directory from bdk-ffi static libs and headers | ||
xcodebuild -create-xcframework \ | ||
-library "${TARGETDIR}/lipo-macos/${RELDIR}/${STATIC_LIB_NAME}" \ | ||
-headers "${NEW_HEADER_DIR}" \ | ||
-library "${TARGETDIR}/aarch64-apple-ios/${RELDIR}/${STATIC_LIB_NAME}" \ | ||
-headers "${NEW_HEADER_DIR}" \ | ||
-library "${TARGETDIR}/lipo-ios-sim/${RELDIR}/${STATIC_LIB_NAME}" \ | ||
-headers "${NEW_HEADER_DIR}" \ | ||
-output "${OUTDIR}/${NAME}.xcframework" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
default: | ||
just --list | ||
|
||
build: | ||
bash ./build-xcframework.sh | ||
|
||
clean: | ||
rm -rf ../target bdkffi.xcframework Sources/BitcoinDevKit/* | ||
|
||
test: | ||
swift test | ||
|
||
test-offline: | ||
swift test --skip LiveElectrumClientTests --skip LiveMemoryWalletTests --skip LiveTransactionTests --skip LiveTxBuilderTests --skip LiveWalletTests |