-
Notifications
You must be signed in to change notification settings - Fork 3
/
build_all.sh
executable file
·114 lines (93 loc) · 3 KB
/
build_all.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
109
110
111
112
113
114
#!/bin/sh
#
# Requires on path:
# - xcodebuild
# - cmake
# - xcpretty
#
# `CONFIGURATION=Debug /bin/sh $0` to build Debug configuration
#
PROJECT_ROOT=$(cd `dirname $0` && pwd)
DERIVED_DATA_PATH="${PROJECT_ROOT}/DerivedData/CZiti"
C_SDK_ROOT="${PROJECT_ROOT}/deps/ziti-tunnel-sdk-c"
: ${CONFIGURATION:="Release"}
# make for iOS, macOS, or All
: ${FOR:="All"}
function build_tsdk {
name=$1
toolchain=$2
echo "Building TSDK for ${name}; toolchain:${toolchain}"
rm -rf ./deps/ziti-tunnel-sdk-c/${name}
cmake_build_type=RelWithDebInfo
if [ "${CONFIGURATION}" == "Debug" ]; then cmake_build_type="Debug"; fi
if [ -n "${ASAN_ENABLED}" ]; then
clang_asan_flags="-DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address"
fi
cmake -DCMAKE_BUILD_TYPE=${cmake_build_type} \
${clang_asan_flags} \
-DTLSUV_TLSLIB=openssl \
-DEXCLUDE_PROGRAMS=ON \
-DZITI_TUNNEL_BUILD_TESTS=OFF \
-DCMAKE_TOOLCHAIN_FILE="${toolchain}" \
-S ./deps/ziti-tunnel-sdk-c -B ./deps/ziti-tunnel-sdk-c/${name}
if [ $? -ne 0 ] ; then
echo "Unable to cmake ${name}"
exit 1
fi
cmake --build ./deps/ziti-tunnel-sdk-c/${name}
if [ $? -ne 0 ] ; then
echo "Unable to cmake build ${name}"
exit 1
fi
}
if ! command -v xcpretty > /dev/null; then
xcpretty() { echo "install xcpretty for more legible xcodebuild output"; cat; }
fi
function build_cziti {
scheme=$1
sdk=$2
arch_flags=$3
if [ -n "${ASAN_ENABLED}" ]; then
asan_flags="-enableAddressSanitizer YES"
fi
echo "Building ${scheme} ${sdk}"
set -o pipefail && xcodebuild build \
-derivedDataPath ./DerivedData/CZiti \
-configuration ${CONFIGURATION} \
-scheme ${scheme} \
${arch_flags} \
${asan_flags} \
-sdk ${sdk} \
| xcpretty
if [ $? -ne 0 ] ; then
echo "Unable to xcodebuild ${scheme} ${sdk}"
exit 1
fi
}
rm -rf ${DERIVED_DATA_PATH}
if [ $? -ne 0 ] ; then
echo "Unable to remove ${DERIVED_DATA_PATH}"
exit 1
fi
toolchain_dir="../../toolchains"
if [ "${FOR}" = "All" ] || [ "${FOR}" = "iOS" ] ; then
build_tsdk 'build-iphoneos-arm64' "${toolchain_dir}/iOS-arm64.cmake"
build_tsdk 'build-iphonesimulator-x86_64' "${toolchain_dir}/iOS-Simulator-x86_64.cmake"
build_tsdk 'build-iphonesimulator-arm64' "${toolchain_dir}/iOS-Simulator-arm64.cmake"
fi
if [ "${FOR}" = "All" ] || [ "${FOR}" = "macOS" ] ; then
build_tsdk 'build-macosx-arm64' "${toolchain_dir}/macOS-arm64.cmake"
build_tsdk 'build-macosx-x86_64' "${toolchain_dir}/macOS-x86_64.cmake"
fi
if [ "${FOR}" = "All" ] || [ "${FOR}" = "iOS" ] ; then
build_cziti 'CZiti-iOS' 'iphoneos' '-arch arm64'
build_cziti 'CZiti-iOS' 'iphonesimulator' '-arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
fi
if [ "${FOR}" = "All" ] || [ "${FOR}" = "macOS" ] ; then
build_cziti 'CZiti-macOS' 'macosx' '-arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
fi
/bin/sh ${PROJECT_ROOT}/make_dist.sh
if [ $? -ne 0 ] ; then
echo "Unable to create distribution"
exit 1
fi