-
Notifications
You must be signed in to change notification settings - Fork 43
/
build-apple.sh
executable file
·62 lines (49 loc) · 1.84 KB
/
build-apple.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
#! /bin/sh
if [ "$(uname)" != "Darwin" ]; then
echo "This script is for macOS only."
exit 1
fi
echo "Setting up the rust environment..."
rustup target add aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios x86_64-apple-darwin aarch64-apple-darwin
cargo install cbindgen
cargo update
echo "Building..."
echo "cargo build --release --target x86_64-apple-darwin"
cargo build --release --target x86_64-apple-darwin
echo "cargo build --release --target aarch64-apple-darwin"
cargo build --release --target aarch64-apple-darwin
echo "cargo build --release --target aarch64-apple-ios"
cargo build --release --target aarch64-apple-ios
echo "cargo build --release --target x86_64-apple-ios"
cargo build --release --target x86_64-apple-ios
echo "cargo build --release --target aarch64-apple-ios-sim"
cargo build --release --target aarch64-apple-ios-sim
echo "Generating includes..."
mkdir -p target/include/
rm -rf target/include/*
cbindgen --config cbindgen.toml -o target/include/overtls.h
cat > target/include/overtls.modulemap <<EOF
framework module overtls {
umbrella header "overtls.h"
export *
module * { export * }
}
EOF
echo "lipo..."
echo "Simulator"
lipo -create \
target/aarch64-apple-ios-sim/release/libovertls.a \
target/x86_64-apple-ios/release/libovertls.a \
-output ./target/libovertls-ios-sim.a
echo "MacOS"
lipo -create \
target/aarch64-apple-darwin/release/libovertls.a \
target/x86_64-apple-darwin/release/libovertls.a \
-output ./target/libovertls-macos.a
echo "Creating XCFramework"
rm -rf ./overtls.xcframework
xcodebuild -create-xcframework \
-library ./target/aarch64-apple-ios/release/libovertls.a -headers ./target/include/ \
-library ./target/libovertls-ios-sim.a -headers ./target/include/ \
-library ./target/libovertls-macos.a -headers ./target/include/ \
-output ./overtls.xcframework