1- set + e
1+ set - e
22
33# validate number of arguments
44if [ " $# " -ne 3 ]; then
4444
4545THIS_BUILD_INFO=" $CMAKE_IOS_PLATFORM "
4646
47+ # === ios-cmake ===
48+
49+ if [ ! -d " ios-cmake" ]; then
50+ echo " ⏳ Cloning ios-cmake..."
51+ git clone --depth 1 --branch 4.5.0 https://github.com/leetal/ios-cmake.git
52+ fi
53+
4754# === OpenSSL ===
4855
4956if [ ! -d openssl-apple ]; then
5057 echo " ⏳ Cloning openssl-apple..."
51- git clone --branch 3.5.200 https://github.com/passepartoutvpn/openssl-apple.git
58+ git clone --depth 1 -- branch 3.5.200 https://github.com/passepartoutvpn/openssl-apple.git
5259fi
5360
5461if [ " $PLATFORM " = " iphonesimulator" ]; then
@@ -80,13 +87,38 @@ echo "ℹ️ OpenSSL prepared in ${first_openssl_sdk_dir}"
8087
8188OPENSSL_ROOT_DIR=$( realpath ${first_openssl_sdk_dir} )
8289
83- # === OTEL wrapper ===
90+ # === OpenTelemetry C++ SDK ===
8491
8592if [ ! -d " opentelemetry-cpp" ]; then
8693 echo " ⏳ Cloning opentelemetry-cpp..."
8794 git clone --depth 1 --branch v1.23.0 https://github.com/open-telemetry/opentelemetry-cpp.git
8895fi
8996
97+ # === Brotli ===
98+
99+ if [ ! -d " brotli" ]; then
100+ echo " ⏳ Cloning Brotli..."
101+ git clone --depth 1 --branch v1.1.0 https://github.com/google/brotli.git
102+ fi
103+
104+ # === Zlib ===
105+
106+ if [ ! -d " zlib" ]; then
107+ echo " ⏳ Cloning Zlib..."
108+ git clone --depth 1 --branch v1.3.1 https://github.com/madler/zlib.git
109+ fi
110+
111+ # === Curl ===
112+
113+ if [ ! -d " curl" ]; then
114+ echo " ⏳ Cloning curl..."
115+ git clone --depth 1 --branch curl-8_15_0 https://github.com/curl/curl.git
116+ fi
117+
118+ # ## ========== End of dependency cloning section ==========
119+
120+ # === Wrapper build ===
121+
90122echo " ⏳ Preparing opentelemetry-cpp wrapper for iOS with CMake..."
91123
92124mkdir -p " wrapper/ios/${BUILD_TYPE} "
@@ -100,28 +132,11 @@ cp -R ${OPENSSL_ROOT_DIR}/* install/
100132
101133# === Brotli ===
102134
103- if [ ! -d " brotli" ]; then
104- echo " ⏳ Cloning Brotli..."
105- git clone --branch v1.1.0 https://github.com/google/brotli.git
106- fi
107-
108- cd brotli
109-
110135echo " ⏳ Building Brotli for iOS..."
111136
112137mkdir -p brotli
113138cd brotli
114139
115- # === ios-cmake ===
116-
117- if [ ! -d " ios-cmake" ]; then
118- echo " ⏳ Cloning ios-cmake..."
119- git clone --branch v4.5.0 https://github.com/leetal/ios-cmake.git
120- cd ios-cmake
121- git checkout 6fa909e133b92343db2d099e0478448c05ffec1a
122- cd ..
123- fi
124-
125140# check if lastBuildInfo.txt has the current CMAKE_IOS_PLATFORM
126141BUILD_BROTLI=$CMAKE_FORCE_REBUILD
127142if [ -f lastBuildInfo.txt ]; then
@@ -143,10 +158,14 @@ if [ "$BUILD_BROTLI" -eq 1 ]; then
143158 -DCMAKE_SYSTEM_NAME=" iOS" \
144159 -DBUILD_SHARED_LIBS=OFF \
145160 -DCMAKE_INSTALL_PREFIX=" $( realpath ../install) " \
146- -DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake
161+ -DCMAKE_TOOLCHAIN_FILE=../ios-cmake/ios.toolchain.cmake \
162+ -DBROTLI_BUNDLED_MODE=ON # disable install, which is failing for iOS
147163
148164 cmake --build . --config $BUILD_TYPE -j$( sysctl -n hw.ncpu)
149- cmake --install . --prefix " $( realpath ../install) "
165+ # cmake --install . --prefix "$(realpath ../install)" - this won't do anything since BROTLI_BUNDLED_MODE=ON
166+ # we need to manually copy the libs & headers instead
167+ cp libbrotli* .a ../install/lib/
168+ cp -R ../../../../brotli/c/include/ ../install/include/
150169
151170 echo " $THIS_BUILD_INFO " > lastBuildInfo.txt
152171else
@@ -157,11 +176,6 @@ cd ..
157176
158177# === Zlib ===
159178
160- if [ ! -d " zlib" ]; then
161- echo " ⏳ Cloning Zlib..."
162- git clone --branch v1.3.1 https://github.com/madler/zlib.git
163- fi
164-
165179echo " ⏳ Building Zlib for iOS..."
166180
167181mkdir -p zlib
@@ -188,6 +202,7 @@ if [ "$BUILD_ZLIB" -eq 1 ]; then
188202 -DZLIB_BUILD_SHARED=OFF \
189203 -DZLIB_BUILD_STATIC=ON \
190204 -DZLIB_BUILD_MINIZIP=OFF \
205+ -DZLIB_BUILD_EXAMPLES=OFF \
191206 -DZLIB_INSTALL=ON \
192207 -DCMAKE_SYSTEM_NAME=" iOS" \
193208 -DCMAKE_INSTALL_PREFIX=" $( realpath ../install) " \
@@ -196,19 +211,20 @@ if [ "$BUILD_ZLIB" -eq 1 ]; then
196211 cmake --build . --config $BUILD_TYPE -j$( sysctl -n hw.ncpu)
197212 cmake --install . --prefix " $( realpath ../install) "
198213
214+ # to avoid issues with linker, remove .dylib files; the current release does not yet respect BUILD_SHARED=OFF
215+ # TODO: remove the below as a new version is released (BUILD_SHARED=OFF is already on main branch)
216+ rm -f ../install/lib/libz* .dylib
217+
199218 echo " $THIS_BUILD_INFO " > lastBuildInfo.txt
200219else
201220 echo " ⏭️ Zlib already built for ${CMAKE_IOS_PLATFORM} , skipping..."
202221fi
203222
204223cd ..
205224
206- mkdir -p curl
225+ # === Curl ===
207226
208- if [ ! -d " curl" ]; then
209- echo " ⏳ Cloning curl..."
210- git clone --depth 1 --branch curl-8_15_0 https://github.com/curl/curl.git
211- fi
227+ mkdir -p curl
212228
213229echo " ⏳ Building curl for iOS..."
214230
@@ -265,11 +281,11 @@ if [ "$BUILD_CURL" -eq 1 ]; then
265281 cmake --build . --config $BUILD_TYPE -j$( sysctl -n hw.ncpu)
266282 cmake --install . --prefix " $( realpath ../install) "
267283
268- if [ " $BUILD_TYPE " = " Debug" ]; then
269- # cocoapods would hardcode -llib*d flags if the debug files existed, which would break compilation
270- # when switching between configurations, therefore all *d libs are renamed to non-d-suffixed in Debug
271- mv ../install/lib/libcurl-d.a ../install/lib/libcurl.a
272- fi
284+ # if [ "$BUILD_TYPE" = "Debug" ]; then
285+ # # cocoapods would hardcode -llib*d flags if the debug files existed, which would break compilation
286+ # # when switching between configurations, therefore all *d libs are renamed to non-d-suffixed in Debug
287+ # mv ../install/lib/libcurl-d.a ../install/lib/libcurl.a
288+ # fi
273289
274290 echo " $THIS_BUILD_INFO " > lastBuildInfo.txt
275291else
278294
279295cd ..
280296
297+ # === Wrapper build ===
298+
281299echo " ⏳ Configuring wrapper for iOS with CMake..."
282300
283301BUILD_WRAPPER=$CMAKE_FORCE_REBUILD
@@ -305,13 +323,6 @@ if [ "$BUILD_WRAPPER" -eq 1 ]; then
305323 cmake --build . --config $BUILD_TYPE -j$( sysctl -n hw.ncpu)
306324 cmake --install . --prefix ./install
307325
308- if [ " $BUILD_TYPE " = " Debug" ]; then
309- # cocoapods would hardcode -llib*d flags if the debug files existed, which would break compilation
310- # when switching between configurations, therefore all *d libs are renamed to non-d-suffixed in Debug
311- mv ../install/lib/libprotobufd.a ../install/lib/libprotobuf.a
312- mv ../install/lib/libprotobuf-lited.a ../install/lib/libprotobuf-lite.a
313- fi
314-
315326 echo " $THIS_BUILD_INFO " > lastBuildInfo.txt
316327else
317328 echo " ⏭️ Wrapper already built for ${CMAKE_IOS_PLATFORM} , skipping..."
@@ -322,5 +333,5 @@ if [ -d ../install ]; then
322333 rm -rf ../install
323334fi
324335
325- echo " Creating install dir copy "
336+ echo " Copying this variant's install dir to ../install "
326337cp -R " $( realpath ./install) " ../install
0 commit comments