tun2proxy/build-apple.sh

57 lines
1.8 KiB
Bash
Raw Normal View History

2024-02-29 07:08:44 +03:30
#! /bin/sh
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
echo "Building..."
2024-03-30 12:30:01 +08:00
echo "cargo build --release --target x86_64-apple-darwin"
2024-02-29 07:08:44 +03:30
cargo build --release --target x86_64-apple-darwin
2024-03-30 12:30:01 +08:00
echo "cargo build --release --target aarch64-apple-darwin"
2024-02-29 07:08:44 +03:30
cargo build --release --target aarch64-apple-darwin
2024-03-30 12:30:01 +08:00
echo "cargo build --release --target aarch64-apple-ios"
2024-08-03 18:21:02 +08:00
cargo build --release --target aarch64-apple-ios --features mimalloc
2024-03-30 12:30:01 +08:00
echo "cargo build --release --target x86_64-apple-ios"
2024-02-29 07:08:44 +03:30
cargo build --release --target x86_64-apple-ios
2024-03-30 12:30:01 +08:00
echo "cargo build --release --target x86_64-apple-ios-sim"
2024-02-29 07:08:44 +03:30
cargo build --release --target aarch64-apple-ios-sim
echo "Generating includes..."
mkdir -p target/include/
2024-03-30 12:30:01 +08:00
rm -rf target/include/*
2024-05-23 21:27:42 +08:00
cbindgen --config cbindgen.toml -l C --cpp-compat -o target/include/tun2proxy.h
2024-03-30 12:30:01 +08:00
cat > target/include/tun2proxy.modulemap <<EOF
2024-03-14 20:28:33 +08:00
framework module tun2proxy {
2024-02-29 07:08:44 +03:30
umbrella header "tun2proxy.h"
export *
module * { export * }
}
EOF
echo "lipo..."
2024-03-14 20:28:33 +08:00
2024-02-29 07:08:44 +03:30
echo "Simulator"
lipo -create \
2024-03-14 20:28:33 +08:00
target/aarch64-apple-ios-sim/release/libtun2proxy.a \
target/x86_64-apple-ios/release/libtun2proxy.a \
-output ./target/libtun2proxy-ios-sim.a
2024-02-29 07:08:44 +03:30
echo "MacOS"
lipo -create \
2024-03-14 20:28:33 +08:00
target/aarch64-apple-darwin/release/libtun2proxy.a \
target/x86_64-apple-darwin/release/libtun2proxy.a \
-output ./target/libtun2proxy-macos.a
2024-02-29 07:08:44 +03:30
echo "Creating XCFramework"
2024-03-14 20:28:33 +08:00
rm -rf ./tun2proxy.xcframework
2024-02-29 07:08:44 +03:30
xcodebuild -create-xcframework \
2024-03-14 20:28:33 +08:00
-library ./target/aarch64-apple-ios/release/libtun2proxy.a -headers ./target/include/ \
-library ./target/libtun2proxy-ios-sim.a -headers ./target/include/ \
-library ./target/libtun2proxy-macos.a -headers ./target/include/ \
-output ./tun2proxy.xcframework