-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild_all.sh
More file actions
executable file
·146 lines (122 loc) · 4.17 KB
/
build_all.sh
File metadata and controls
executable file
·146 lines (122 loc) · 4.17 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/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"}
# make for simulators
: ${SIMS:="Yes"}
function build_tsdk {
name=$1
toolchain=$2
echo "Building TSDK for ${name}; toolchain:${toolchain}"
rm -rf ./deps/ziti-tunnel-sdk-c/${name}
local for_mac=""
if echo "${name}" | grep -q "macosx"; then for_mac=y; fi
cmake_build_type=RelWithDebInfo
if [ "${CONFIGURATION}" == "Debug" ]; then cmake_build_type="Debug"; fi
local clang_asan_flags=""
if [ -n "${ASAN_ENABLED}" -a -n "${for_mac}" ]; 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 \
-DVCPKG_INSTALL_OPTIONS="--overlay-ports=./deps/vcpkg-overlays/json-c" \
-DEXCLUDE_PROGRAMS=ON \
-DZITI_TUNNEL_BUILD_TESTS=OFF \
-DCMAKE_TOOLCHAIN_FILE="${toolchain}" \
-DCMAKE_INSTALL_PREFIX=./deps/ziti-tunnel-sdk-c/${name}/cmake_installed \
-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
# installing would let us clean up the lib/include paths in the xcode project
# in theory, but at the moment the install targets in the cmake files are not
# quite accurate.
#cmake --install ./deps/ziti-tunnel-sdk-c/${name}
#if [ $? -ne 0 ] ; then
# echo "Unable to cmake install ${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}" -a "${FOR}" = "macOS" ]; 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"
fi
if [ "${SIMS}" = "Yes" ] && [ "${FOR}" = "All" ] || [ "${FOR}" = "iOS" ] ; then
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
if [ "${ONLY_ACTIVE_ARCH}" = "YES" ]; then
active_arch=$(arch)
build_tsdk "build-macosx-${active_arch}" "${toolchain_dir}/macOS-${active_arch}.cmake"
else
build_tsdk 'build-macosx-arm64' "${toolchain_dir}/macOS-arm64.cmake"
build_tsdk 'build-macosx-x86_64' "${toolchain_dir}/macOS-x86_64.cmake"
fi
fi
if [ "${FOR}" = "All" ] || [ "${FOR}" = "iOS" ] ; then
build_cziti 'CZiti-iOS' 'iphoneos' '-arch arm64'
fi
if [ "${SIMS}" = "Yes" ] && [ "${FOR}" = "All" ] || [ "${FOR}" = "iOS" ] ; then
build_cziti 'CZiti-iOS' 'iphonesimulator' '-arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
fi
if [ "${FOR}" = "All" ] || [ "${FOR}" = "macOS" ] ; then
if [ "${ONLY_ACTIVE_ARCH}" = "YES" ]; then
active_arch=$(arch)
build_cziti 'CZiti-macOS' 'macosx' "-arch ${active_arch} ONLY_ACTIVE_ARCH=YES"
else
build_cziti 'CZiti-macOS' 'macosx' '-arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
fi
fi
/bin/sh ${PROJECT_ROOT}/make_dist.sh
if [ $? -ne 0 ] ; then
echo "Unable to create distribution"
exit 1
fi