Add M1 target support to build.sh
This commit is contained in:
parent
250df250ff
commit
a33e856b48
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,4 +8,5 @@ DerivedData/
|
|||||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
bdkFFI.xcframework.zip
|
bdkFFI.xcframework.zip
|
||||||
bdkFFI
|
bdkFFI
|
||||||
|
libbdkffi.a
|
||||||
bdkFFI.h
|
bdkFFI.h
|
||||||
|
@ -24,8 +24,8 @@ let package = Package(
|
|||||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||||
.binaryTarget(
|
.binaryTarget(
|
||||||
name: "bdkFFI",
|
name: "bdkFFI",
|
||||||
url: "https://github.com/notmandatory/bdk-swift/releases/download/0.1.3/bdkFFI.xcframework.zip",
|
url: "https://github.com/notmandatory/bdk-swift/releases/download/0.1.7/bdkFFI.xcframework.zip",
|
||||||
checksum: "c0b1e3ea09376b3f316d7d83575e1cd513fc4ad39ef8cf01120a3a1d7757fb97"),
|
checksum: "dc51c5c61b78e06fba45fe7d55978726f6f6bb609c2b369f12f3f2e5c24b9ed5"),
|
||||||
// .binaryTarget(name: "bdkFFI", path: "./bdkFFI.xcframework"),
|
// .binaryTarget(name: "bdkFFI", path: "./bdkFFI.xcframework"),
|
||||||
.target(
|
.target(
|
||||||
name: "BitcoinDevKit",
|
name: "BitcoinDevKit",
|
||||||
|
@ -6,27 +6,16 @@
|
|||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>LibraryIdentifier</key>
|
<key>LibraryIdentifier</key>
|
||||||
<string>macos-x86_64</string>
|
<string>macos-arm64_x86_64</string>
|
||||||
<key>LibraryPath</key>
|
|
||||||
<string>bdkFFI.framework</string>
|
|
||||||
<key>SupportedArchitectures</key>
|
|
||||||
<array>
|
|
||||||
<string>x86_64</string>
|
|
||||||
</array>
|
|
||||||
<key>SupportedPlatform</key>
|
|
||||||
<string>macos</string>
|
|
||||||
</dict>
|
|
||||||
<dict>
|
|
||||||
<key>LibraryIdentifier</key>
|
|
||||||
<string>ios-arm64</string>
|
|
||||||
<key>LibraryPath</key>
|
<key>LibraryPath</key>
|
||||||
<string>bdkFFI.framework</string>
|
<string>bdkFFI.framework</string>
|
||||||
<key>SupportedArchitectures</key>
|
<key>SupportedArchitectures</key>
|
||||||
<array>
|
<array>
|
||||||
<string>arm64</string>
|
<string>arm64</string>
|
||||||
|
<string>x86_64</string>
|
||||||
</array>
|
</array>
|
||||||
<key>SupportedPlatform</key>
|
<key>SupportedPlatform</key>
|
||||||
<string>ios</string>
|
<string>macos</string>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>LibraryIdentifier</key>
|
<key>LibraryIdentifier</key>
|
||||||
@ -43,6 +32,18 @@
|
|||||||
<key>SupportedPlatformVariant</key>
|
<key>SupportedPlatformVariant</key>
|
||||||
<string>simulator</string>
|
<string>simulator</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>LibraryIdentifier</key>
|
||||||
|
<string>ios-arm64</string>
|
||||||
|
<key>LibraryPath</key>
|
||||||
|
<string>bdkFFI.framework</string>
|
||||||
|
<key>SupportedArchitectures</key>
|
||||||
|
<array>
|
||||||
|
<string>arm64</string>
|
||||||
|
</array>
|
||||||
|
<key>SupportedPlatform</key>
|
||||||
|
<string>ios</string>
|
||||||
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>XFWK</string>
|
<string>XFWK</string>
|
||||||
|
61
build.sh
61
build.sh
@ -6,47 +6,64 @@ pushd bdk-ffi
|
|||||||
echo "Confirm bdk-ffi rust lib builds"
|
echo "Confirm bdk-ffi rust lib builds"
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|
||||||
## build bdk-ffi rust libs for apple targets
|
echo "Generate bdk-ffi swift bindings"
|
||||||
echo "Build bdk-ffi libs for apple targets"
|
uniffi-bindgen generate src/bdk.udl --no-format --out-dir ../Sources/BitcoinDevKit --language swift
|
||||||
|
|
||||||
TARGET_TRIPLES=("x86_64-apple-darwin" "x86_64-apple-ios" "aarch64-apple-ios")
|
## build bdk-ffi rust libs for apple targets and add to xcframework
|
||||||
|
echo "Build bdk-ffi libs for apple targets and add to xcframework"
|
||||||
|
|
||||||
|
TARGET_TRIPLES=("x86_64-apple-darwin" "aarch64-apple-darwin" "x86_64-apple-ios" "aarch64-apple-ios")
|
||||||
|
#XCFRAMEWORK_LIBS=""
|
||||||
for TARGET in ${TARGET_TRIPLES[@]}; do
|
for TARGET in ${TARGET_TRIPLES[@]}; do
|
||||||
echo "Build bdk-ffi lib for target $TARGET"
|
echo "Build bdk-ffi lib for target $TARGET"
|
||||||
cargo build --release --target $TARGET
|
cargo build --release --target $TARGET
|
||||||
|
#XCFRAMEWORK_LIBS="$XCFRAMEWORK_LIBS -library target/$TARGET/release/libbdkffi.a"
|
||||||
done
|
done
|
||||||
|
# special build for M1 ios simulator
|
||||||
|
cargo +nightly build --release -Z build-std --target aarch64-apple-ios-sim
|
||||||
|
|
||||||
|
echo "Create lipo static libs for ios-sim to support M1"
|
||||||
|
mkdir -p target/lipo-ios-sim/release
|
||||||
|
lipo target/aarch64-apple-ios-sim/release/libbdkffi.a target/x86_64-apple-ios/release/libbdkffi.a -create -output target/lipo-ios-sim/release/libbdkffi.a
|
||||||
|
|
||||||
|
echo "Create lipo static libs for macos to support M1"
|
||||||
|
mkdir -p target/lipo-macos/release
|
||||||
|
lipo target/aarch64-apple-darwin/release/libbdkffi.a target/x86_64-apple-darwin/release/libbdkffi.a -create -output target/lipo-macos/release/libbdkffi.a
|
||||||
|
|
||||||
|
#echo "Create xcframework with xcodebuild"
|
||||||
|
#xcodebuild -create-xcframework \
|
||||||
|
# -library target/lipo-ios-sim/release/libbdkffi.a \
|
||||||
|
# -library target/lipo-macos/release/libbdkffi.a \
|
||||||
|
# -library target/aarch64-apple-ios/release/libbdkffi.a \
|
||||||
|
# -output ../bdkFFI.xcframework
|
||||||
|
|
||||||
echo "Generate bdk-ffi swift bindings"
|
|
||||||
uniffi-bindgen generate src/bdk.udl --no-format --out-dir ../Sources/BitcoinDevKit --language swift
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# rename bdk.swift bindings to BitcoinDevKit.swift
|
# rename bdk.swift bindings to BitcoinDevKit.swift
|
||||||
mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
|
mv Sources/BitcoinDevKit/bdk.swift Sources/BitcoinDevKit/BitcoinDevKit.swift
|
||||||
|
|
||||||
# copy bdkFFI.h to bdkFFI.xcframework platforms
|
XCFRAMEWORK_LIBS=("ios-arm64" "ios-arm64_x86_64-simulator" "macos-arm64_x86_64")
|
||||||
PLATFORMS=("macos-x86_64" "ios-arm64_x86_64-simulator" "ios-arm64")
|
for LIB in ${XCFRAMEWORK_LIBS[@]}; do
|
||||||
for PLATFORM in ${PLATFORMS[@]}; do
|
# copy possibly updated header file
|
||||||
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/$PLATFORM/bdkFFI.framework/Headers
|
cp Sources/BitcoinDevKit/bdkFFI.h bdkFFI.xcframework/$LIB/bdkFFI.framework/Headers
|
||||||
done
|
done
|
||||||
|
|
||||||
|
echo "Copy libbdkffi.a files to bdkFFI.xcframework/bdkFFI"
|
||||||
|
cp bdk-ffi/target/aarch64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
|
||||||
|
cp bdk-ffi/target/lipo-ios-sim/release/libbdkffi.a bdkFFI.xcframework/ios-arm64_x86_64-simulator/bdkFFI.framework/bdkFFI
|
||||||
|
cp bdk-ffi/target/lipo-macos/release/libbdkffi.a bdkFFI.xcframework/macos-arm64_x86_64/bdkFFI.framework/bdkFFI
|
||||||
|
|
||||||
# remove unneed .h and .modulemap files
|
# remove unneed .h and .modulemap files
|
||||||
rm Sources/BitcoinDevKit/bdkFFI.h
|
rm Sources/BitcoinDevKit/bdkFFI.h
|
||||||
rm Sources/BitcoinDevkit/bdkFFI.modulemap
|
rm Sources/BitcoinDevkit/bdkFFI.modulemap
|
||||||
|
|
||||||
# add bdkFFI libs to bdkFFI.xcframework
|
|
||||||
|
|
||||||
# macos-x86_64 platform
|
|
||||||
cp bdk-ffi/target/x86_64-apple-darwin/release/libbdkffi.a bdkFFI.xcframework/macos-x86_64/bdkFFI.framework/bdkFFI
|
|
||||||
|
|
||||||
# ios-arm64 platform
|
|
||||||
cp bdk-ffi/target/aarch64-apple-ios/release/libbdkffi.a bdkFFI.xcframework/ios-arm64/bdkFFI.framework/bdkFFI
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# TODO add license info
|
# TODO add license info
|
||||||
|
|
||||||
# remove any existing bdkFFI.xcframework.zip
|
if test -f "bdkFFI.xcframework.zip"; then
|
||||||
rm bdkFFI.xcframework.zip
|
echo "Remove old bdkFFI.xcframework.zip"
|
||||||
|
rm bdkFFI.xcframework.zip
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# zip bdkFFI.xcframework directory into a bundle for distribution
|
# zip bdkFFI.xcframework directory into a bundle for distribution
|
||||||
zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
|
zip -9 -r bdkFFI.xcframework.zip bdkFFI.xcframework
|
||||||
|
Loading…
x
Reference in New Issue
Block a user