@@ -15,6 +15,8 @@ C_SDK_ROOT="${PROJECT_ROOT}/deps/ziti-tunnel-sdk-c"
1515: ${CONFIGURATION:= " Release" }
1616# make for iOS, macOS, or All
1717: ${FOR:= " All" }
18+ # make for simulators
19+ : ${SIMS:= " Yes" }
1820
1921function build_tsdk {
2022 name=$1
@@ -23,10 +25,14 @@ function build_tsdk {
2325 echo " Building TSDK for ${name} ; toolchain:${toolchain} "
2426 rm -rf ./deps/ziti-tunnel-sdk-c/${name}
2527
28+ local for_mac=" "
29+ if echo " ${name} " | grep -q " macosx" ; then for_mac=y; fi
30+
2631 cmake_build_type=RelWithDebInfo
2732 if [ " ${CONFIGURATION} " == " Debug" ]; then cmake_build_type=" Debug" ; fi
2833
29- if [ -n " ${ASAN_ENABLED} " -a " ${FOR} " = " macOS" ]; then
34+ local clang_asan_flags=" "
35+ if [ -n " ${ASAN_ENABLED} " -a -n " ${for_mac} " ]; then
3036 clang_asan_flags=" -DCMAKE_C_FLAGS=-fsanitize=address -DCMAKE_CXX_FLAGS=-fsanitize=address"
3137 fi
3238
@@ -37,6 +43,7 @@ function build_tsdk {
3743 -DEXCLUDE_PROGRAMS=ON \
3844 -DZITI_TUNNEL_BUILD_TESTS=OFF \
3945 -DCMAKE_TOOLCHAIN_FILE=" ${toolchain} " \
46+ -DCMAKE_INSTALL_PREFIX=./deps/ziti-tunnel-sdk-c/${name} /cmake_installed \
4047 -S ./deps/ziti-tunnel-sdk-c -B ./deps/ziti-tunnel-sdk-c/${name}
4148
4249 if [ $? -ne 0 ] ; then
@@ -49,6 +56,15 @@ function build_tsdk {
4956 echo " Unable to cmake build ${name} "
5057 exit 1
5158 fi
59+
60+ # installing would let us clean up the lib/include paths in the xcode project
61+ # in theory, but at the moment the install targets in the cmake files are not
62+ # quite accurate.
63+ # cmake --install ./deps/ziti-tunnel-sdk-c/${name}
64+ # if [ $? -ne 0 ] ; then
65+ # echo "Unable to cmake install ${name}"
66+ # exit 1
67+ # fi
5268}
5369
5470if ! command -v xcpretty > /dev/null; then
89105toolchain_dir=" ../../toolchains"
90106if [ " ${FOR} " = " All" ] || [ " ${FOR} " = " iOS" ] ; then
91107 build_tsdk ' build-iphoneos-arm64' " ${toolchain_dir} /iOS-arm64.cmake"
108+ fi
109+
110+ if [ " ${SIMS} " = " Yes" ] && [ " ${FOR} " = " All" ] || [ " ${FOR} " = " iOS" ] ; then
92111 build_tsdk ' build-iphonesimulator-x86_64' " ${toolchain_dir} /iOS-Simulator-x86_64.cmake"
93112 build_tsdk ' build-iphonesimulator-arm64' " ${toolchain_dir} /iOS-Simulator-arm64.cmake"
94113fi
95114
96115if [ " ${FOR} " = " All" ] || [ " ${FOR} " = " macOS" ] ; then
97- build_tsdk ' build-macosx-arm64' " ${toolchain_dir} /macOS-arm64.cmake"
98- build_tsdk ' build-macosx-x86_64' " ${toolchain_dir} /macOS-x86_64.cmake"
116+ if [ " ${ONLY_ACTIVE_ARCH} " = " YES" ]; then
117+ active_arch=$( arch)
118+ build_tsdk " build-macosx-${active_arch} " " ${toolchain_dir} /macOS-${active_arch} .cmake"
119+ else
120+ build_tsdk ' build-macosx-arm64' " ${toolchain_dir} /macOS-arm64.cmake"
121+ build_tsdk ' build-macosx-x86_64' " ${toolchain_dir} /macOS-x86_64.cmake"
122+ fi
99123fi
100124
101-
102125if [ " ${FOR} " = " All" ] || [ " ${FOR} " = " iOS" ] ; then
103126 build_cziti ' CZiti-iOS' ' iphoneos' ' -arch arm64'
127+ fi
128+
129+ if [ " ${SIMS} " = " Yes" ] && [ " ${FOR} " = " All" ] || [ " ${FOR} " = " iOS" ] ; then
104130 build_cziti ' CZiti-iOS' ' iphonesimulator' ' -arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
105131fi
106132
107133if [ " ${FOR} " = " All" ] || [ " ${FOR} " = " macOS" ] ; then
108- build_cziti ' CZiti-macOS' ' macosx' ' -arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
134+ if [ " ${ONLY_ACTIVE_ARCH} " = " YES" ]; then
135+ active_arch=$( arch)
136+ build_cziti ' CZiti-macOS' ' macosx' " -arch ${active_arch} ONLY_ACTIVE_ARCH=YES"
137+ else
138+ build_cziti ' CZiti-macOS' ' macosx' ' -arch x86_64 -arch arm64 ONLY_ACTIVE_ARCH=NO'
139+ fi
109140fi
110141
111142/bin/sh ${PROJECT_ROOT} /make_dist.sh
0 commit comments