This repository has been archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cargo_xcframeworks.sh
99 lines (78 loc) · 3.82 KB
/
cargo_xcframeworks.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh -e
# This script demonstrates archive and create action on frameworks and libraries
#
echo "▸ Update toolchain"
rustup update
echo "x86_64-apple-ios-macabi and aarch64-apple-ios-macabi require the nightly toolchain"
rustup toolchain install nightly
#rustup default nightly
# to allow for abi builds from the nightly toolchain for xargo...
rustup component add rust-src
echo "▸ Install xargo"
cargo install xargo
echo "▸ Install targets"
rustup target add x86_64-apple-ios
rustup target add aarch64-apple-ios
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-ios-sim
rustup target add aarch64-apple-ios-macabi
rustup target add x86_64-apple-ios-macabi
rustup target add aarch64-apple-tvos
echo "▸ Build x86_64-apple-ios"
cargo build --target x86_64-apple-ios --package automerge-c --release
echo "▸ Build aarch64-apple-ios-sim"
xargo build -Zbuild-std --target aarch64-apple-ios-sim --package automerge-c --release
echo "▸ Build aarch64-apple-ios"
cargo build --target aarch64-apple-ios --package automerge-c --release
echo "▸ Build aarch64-apple-darwin"
cargo build --target aarch64-apple-darwin --package automerge-c --release
echo "▸ Build x86_64-apple-darwin"
cargo build --target x86_64-apple-darwin --package automerge-c --release
echo "▸ x86_64-apple-ios-macabi"
xargo build -Zbuild-std --target x86_64-apple-ios-macabi --package automerge-c --release
echo "▸ aarch64-apple-ios-macabi"
#xargo build --target aarch64-apple-ios-macabi --package automerge-c --release
xargo build -Zbuild-std --target aarch64-apple-ios-macabi --package automerge-c --release
# echo "▸ aarch64-apple-tvos"
# xargo build -Zbuild-std --target aarch64-apple-tvos --package automerge-c --release
# multiple errors when building the std. library for tvOS w/ nightly
echo "▸ Lipo macOS"
mkdir -p ./target/apple-darwin/release
lipo -create \
./target/x86_64-apple-darwin/release/libautomerge.a \
./target/aarch64-apple-darwin/release/libautomerge.a \
-output ./target/apple-darwin/release/libautomerge.a
echo "▸ Lipo simulator"
mkdir -p ./target/apple-ios-simulator/release
lipo -create \
./target/x86_64-apple-ios/release/libautomerge.a \
./target/aarch64-apple-ios-sim/release/libautomerge.a \
-output ./target/apple-ios-simulator/release/libautomerge.a
echo "▸ Lipo ios-macabi"
mkdir -p ./target/apple-ios-macabi/release
lipo -create \
./target/aarch64-apple-ios-macabi/release/libautomerge.a \
./target/x86_64-apple-ios-macabi/release/libautomerge.a \
-output ./target/apple-ios-macabi/release/libautomerge.a
echo "#####################"
rm -rf ./xcframework/AutomergeBackend.xcframework
mkdir -p automerge-swift-backend/Headers
cp automerge-c/automerge.h automerge-swift-backend/Headers
cp automerge-swift-backend/module.modulemap automerge-swift-backend/Headers
echo "▸ Create AutomergeRSBackend.xcframework"
xcodebuild -create-xcframework \
-library ./target/apple-ios-simulator/release/libautomerge.a \
-headers ./automerge-swift-backend/Headers \
-library ./target/aarch64-apple-ios/release/libautomerge.a \
-headers ./automerge-swift-backend/Headers \
-library ./target/apple-ios-macabi/release/libautomerge.a \
-headers ./automerge-swift-backend/Headers \
-library ./target/apple-darwin/release/libautomerge.a \
-headers ./automerge-swift-backend/Headers \
-output ./xcframework/AutomergeBackend.xcframework
echo "▸ Compress AutomergeRSBackend.xcframework"
ditto -c -k --sequesterRsrc --keepParent ./xcframework/AutomergeBackend.xcframework ./automerge-swift-backend/AutomergeBackend.xcframework.zip
echo "▸ Compute AutomergeRSBackend.xcframework checksum"
cd automerge-swift-backend
swift package compute-checksum ./AutomergeBackend.xcframework.zip