-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-boringssl.sh
executable file
·108 lines (86 loc) · 2.74 KB
/
build-boringssl.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
100
101
102
103
104
105
106
107
108
#!/bin/sh
set -e
build_framework()
{
ARCH=$1
SYSROOT=$2
TARGET_VERSION=$3
if [ -d build ]; then
rm -rf build
fi
mkdir build
cd build
echo "Build for architecture $ARCH for version $TARGET_VERSION"
cmake -DCMAKE_OSX_SYSROOT=$SYSROOT -DCMAKE_OSX_ARCHITECTURES=$ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$TARGET_VERSION ..
make
mkdir -p ../$ARCH/openssl.framework/Headers
libtool -no_warning_for_no_symbols -static -o ../$ARCH/openssl.framework/openssl crypto/libcrypto.a ssl/libssl.a
cp -r ../include/openssl/* ../$ARCH/openssl.framework/Headers/
echo "Created openssl.framework for $ARCH"
cd ..
}
# Check SDK locations
XCODE_DEV_PATH="/Applications/Xcode.app/Contents/Developer"
if command -v xcode-select 2>&1 >/dev/null
then
XCODE_DEV_PATH=$(xcode-select -p)
echo "Using Xcode DEV tools at $XCODE_DEV_PATH"
fi
PHONE_SDK="$XCODE_DEV_PATH/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
SIMULATOR_SDK="$XCODE_DEV_PATH/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
ARM64_SIMULATOR_SDK="$XCODE_DEV_PATH/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
if [ ! -d "$PHONE_SDK" ]; then
echo "PHONE SDK does not exist at location!"
exit
fi
if [ ! -d "$SIMULATOR_SDK" ]; then
echo "SIMULATOR SDK does not exist at location!"
exit
fi
if [ ! -d "$ARM64_SIMULATOR_SDK" ]; then
echo "SIMULATOR SDK for ARM64 does not exist at location!"
exit
fi
# Clone boringSSL
if [ -d boringssl ]; then
rm -rf boringssl
fi
git clone https://boringssl.googlesource.com/boringssl
cd boringssl
boringssl_version=$(git rev-parse --short HEAD)
echo "BoringSSL version: $boringssl_version"
# Build frameworks
build_framework arm64 $PHONE_SDK '15.0'
if [ -d iphoneos ]; then
rm -rf iphoneos
fi
mkdir iphoneos
mv arm64 iphoneos
build_framework x86_64 $SIMULATOR_SDK '15.0'
build_framework arm64 $ARM64_SIMULATOR_SDK '15.0'
# Create universal framework output directory for simulator
if [ -d iphonesimulator ]; then
rm -rf iphonesimulator
fi
mkdir -p iphonesimulator/openssl.framework
# Create universal framework for simulator
echo "Combine simulator archs..."
lipo -create -output "iphonesimulator/openssl.framework/openssl" "arm64/openssl.framework/openssl" "x86_64/openssl.framework/openssl"
cp -r arm64/openssl.framework/Headers iphonesimulator/openssl.framework/
# Create xcframework output directory
if [ -d ../output ]; then
rm -rf ../output
fi
mkdir ../output
# Create xcframework
echo "Create xcframework..."
xcodebuild -create-xcframework -framework iphoneos/arm64/openssl.framework -framework iphonesimulator/openssl.framework -output "../output/openssl.xcframework"
# Cleanup
rm -rf build
rm -rf iphoneos
rm -rf arm64
rm -rf x86_64
rm -rf iphonesimulator
cd ..
echo "Done!"
echo "Created output at "$PWD"/output/"