-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathbuild.sh
executable file
·549 lines (509 loc) · 19.5 KB
/
build.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
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
#!/bin/bash
# This script builds openssl+libcurl libraries for MacOS, iOS and tvOS
#
# Jason Cox, @jasonacox
# https://github.com/jasonacox/Build-OpenSSL-cURL
#
# Ensure we stop if build failure occurs
set -e
################################################
# EDIT this section to Select Default Versions #
################################################
OPENSSL="3.0.15" # https://www.openssl.org/source/ - LTS Version
LIBCURL="8.11.1" # https://curl.haxx.se/download.html
NGHTTP2="1.64.0" # https://nghttp2.org/
################################################
# Build Machine
BUILD_MACHINE=`uname -m`
BUILD_CMD=$*
# Script Version
SCRIPT_VERSION="1.0.1"
# Compile Cache - Optional
# export CMAKE_CXX_COMPILER_LAUNCHER="ccache"
# Set minimum OS versions for target
MACOS_X86_64_VERSION="" # Empty = use host version
MACOS_ARM64_VERSION="" # Min supported is MacOS 11.0 Big Sur
CATALYST_IOS="15.0" # Min supported is iOS 15.0 for Mac Catalyst
IOS_MIN_SDK_VERSION="8.0"
TVOS_MIN_SDK_VERSION="9.0"
# Semantic Version Comparison
version_lte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
if [ -z "${MACOS_X86_64_VERSION}" ]; then
MACOS_X86_64_VERSION=$(sw_vers -productVersion)
fi
if [ -z "${MACOS_ARM64_VERSION}" ]; then
MACOS_ARM64_VERSION=$(sw_vers -productVersion)
fi
if version_lte $MACOS_ARM64_VERSION 11.0; then
MACOS_ARM64_VERSION="11.0" # Min support for Apple Silicon is 11.0
fi
# Defaults
BUILDFOR="all"
# Global flags
engine=""
buildnghttp2="-n"
disablebitcode="-b"
colorflag=""
catalyst=""
sslv3=""
autobuild=""
# Formatting
default="\033[39m"
white="\033[97m"
green="\033[32m"
red="\033[91m"
yellow="\033[33m"
bold="\033[0m${white}\033[1m"
subbold="\033[0m${green}"
normal="${white}\033[0m"
dim="\033[0m${white}\033[2m"
alert="\033[0m${red}\033[1m"
alertdim="\033[0m${red}\033[2m"
archbold="\033[0m${yellow}\033[1m"
# Set trap to alert on error and show line
trap 'echo -e "${alert}** ERROR occurred on line $LINENO ($0) - exit code: $?"' ERR
trap 'echo -e "\n${alertdim}Cancelled by User${normal}"; exit 1' INT
# Show Usage
usage () {
echo -e "${bold}Build-OpenSSL-cURL${dim} - v$SCRIPT_VERSION"
echo
echo -e "${bold}Usage:${normal}"
echo
echo -e " ${subbold}$0${normal} [-o ${dim}<OpenSSL version>${normal}] [-c ${dim}<curl version>${normal}] [-n ${dim}<nghttp2 version>${normal}] [-d] [-e] [-3] [-x] [-h] [...]"
echo
echo " -o <version> Build OpenSSL version (default $OPENSSL)"
echo " -c <version> Build curl version (default $LIBCURL)"
echo " -n <version> Build nghttp2 version (default $NGHTTP2)"
echo " -d Compile without HTTP2 support"
echo " -e Compile with OpenSSL engine support"
echo " -b Compile without bitcode (deprecated)"
echo " -m Compile Mac Catalyst library"
echo " -u <version> Mac Catalyst iOS min target version (default $CATALYST_IOS)"
echo " -3 Compile with SSLv3"
echo " -s <version> iOS min target version (default $IOS_MIN_SDK_VERSION)"
echo " -t <version> tvOS min target version (default $TVOS_MIN_SDK_VERSION)"
echo " -i <version> macOS 86_64 min target version (default $MACOS_X86_64_VERSION)"
echo " -a <version> macOS arm64 min target version (default $MACOS_ARM64_VERSION)"
echo " -x No color output"
echo " -p <platform> Build only for specified platform (iOS, tvOS, macOS, or all [default])"
echo " -y Skip build confirmation"
echo " -h Show usage"
echo
exit 127
}
# Process command line arguments
while getopts "o:c:n:u:s:t:i:a:p:debm3xhy\?" o; do
case "${o}" in
o) OPENSSL="${OPTARG}" ;;
c) LIBCURL="${OPTARG}" ;;
n) NGHTTP2="${OPTARG}" ;;
d) buildnghttp2="" ;;
e) engine="-e" ;;
b) disablebitcode="-b" ;;
m) catalyst="-m" ;;
u) catalyst="-m -u ${OPTARG}"; CATALYST_IOS="${OPTARG}" ;;
3)
echo "WARNING: SSLv3 is requested. SSLv3 is not secure and has been deprecated."
echo "If you proceed, builds may fail as SSLv3 is no longer supported by curl."
read -p "Do you want to continue (y/N)? " choice
case "$choice" in
y|Y ) echo "Continuing with SSLv3 build"; echo "" ;;
* ) echo "Exiting"; exit 1 ;;
esac
sslv3="-3"
;;
s) IOS_MIN_SDK_VERSION="${OPTARG}" ;;
t) TVOS_MIN_SDK_VERSION="${OPTARG}" ;;
i) MACOS_X86_64_VERSION="${OPTARG}" ;;
a) MACOS_ARM64_VERSION="${OPTARG}" ;;
x)
bold=""; subbold=""; normal=""; dim=""; alert=""; alertdim=""; archbold=""
colorflag="-x"
;;
p)
BUILDFOR=$(echo "$OPTARG" | tr '[:upper:]' '[:lower:]')
BUILDFORARGS="-p $BUILDFOR"
if [ "$BUILDFOR" == "all" ]; then
BUILDFORARGS=""
elif [ "$BUILDFOR" != "ios" ] && [ "$BUILDFOR" != "tvos" ] && [ "$BUILDFOR" != "macos" ]; then
echo -e "${alert}Invalid platform requested${normal}: $BUILDFOR"
echo "Please specify iOS, tvOS or macOS"
exit 127
fi
catalyst="" # Clear catalyst if not building for all
;;
y) autobuild="-y" ;;
*) usage ;;
esac
done
shift $((OPTIND-1))
# Set OS min versions
OSARGS="-s ${IOS_MIN_SDK_VERSION} -t ${TVOS_MIN_SDK_VERSION} -i ${MACOS_X86_64_VERSION} -a ${MACOS_ARM64_VERSION}"
## Welcome
echo -e "${bold}Build-OpenSSL-cURL${dim} - v$SCRIPT_VERSION"
echo
echo -e " - OpenSSL version: ${subbold}${OPENSSL}${dim}"
echo -e " - cURL version: ${subbold}${LIBCURL}${dim}"
if [ "$buildnghttp2" == "" ]; then
echo ""
echo -n "This script builds OpenSSL and libcurl for "
else
echo -e " - nghttp2 version: ${subbold}${NGHTTP2}${dim}"
echo ""
echo -n "This script builds OpenSSL, nghttp2 and libcurl for "
fi
case "$BUILDFOR" in
ios) echo -e "${archbold}iOS${dim}" ;;
tvos) echo -e "${archbold}tvOS${dim}" ;;
macos) echo -e "${archbold}macOS${dim}" ;;
*)
if [ "$catalyst" != "" ]; then
echo -e "${archbold}macOS${dim}, ${archbold}catalyst${dim}, ${archbold}iOS${dim} and ${archbold}tvOS${dim}"
else
echo -e "${archbold}macOS${dim}, ${archbold}iOS${dim} and ${archbold}tvOS${dim}"
fi
;;
esac
## Ask for confirmation to continue
if [ "$autobuild" == "" ]; then
read -p "Continue (Y/n)? " choice
case "$choice" in
n|N ) echo "Exiting"; exit 1 ;;
* ) echo "Continuing..."; echo "" ;;
esac
fi
## Start Counter
START=$(date +%s)
# Starting with OpenSSL 3.0 force nobitcode
if [[ "$OPENSSL" = "3.0"* ]]; then
disablebitcode="-b"
fi
## OpenSSL Build
echo
cd openssl
echo -e "${bold}Building OpenSSL${normal}"
./openssl-build.sh -v "$OPENSSL" $engine $colorflag $catalyst $sslv3 $OSARGS $BUILDFORARGS
cd ..
## Nghttp2 Build
if [ "$buildnghttp2" == "" ]; then
NGHTTP2="NONE"
else
echo
echo -e "${bold}Building nghttp2 for HTTP2 support${normal}"
cd nghttp2
./nghttp2-build.sh -v "$NGHTTP2" $colorflag $catalyst $OSARGS $BUILDFORARGS
cd ..
fi
## Curl Build
echo
echo -e "${bold}Building Curl${normal}"
cd curl
./libcurl-build.sh -v "$LIBCURL" $disablebitcode $colorflag $buildnghttp2 $catalyst $sslv3 $OSARGS $BUILDFORARGS
cd ..
## Archive Libraries and Clean Up
echo
echo -e "${bold}Libraries...${normal}"
echo
echo -e "${subbold}openssl${normal} [${dim}$OPENSSL${normal}]${dim}"
xcrun -sdk iphoneos lipo -info openssl/*/lib/*.a
if [ "$buildnghttp2" != "" ]; then
echo
echo -e "${subbold}nghttp2 (rename to libnghttp2.a)${normal} [${dim}$NGHTTP2${normal}]${dim}"
xcrun -sdk iphoneos lipo -info nghttp2/lib/*.a
fi
echo
echo -e "${subbold}libcurl (rename to libcurl.a)${normal} [${dim}$LIBCURL${normal}]${dim}"
xcrun -sdk iphoneos lipo -info curl/lib/*.a
ARCHIVE="archive/libcurl-$LIBCURL-openssl-$OPENSSL-nghttp2-$NGHTTP2"
echo
echo -e "${bold}Creating archive with XCFrameworks for release v$LIBCURL...${dim}"
echo " See $ARCHIVE"
rm -rf "$ARCHIVE"
mkdir -p "$ARCHIVE"
mkdir -p "$ARCHIVE/include/openssl"
mkdir -p "$ARCHIVE/include/curl"
mkdir -p "$ARCHIVE/lib/iOS"
mkdir -p "$ARCHIVE/lib/iOS-simulator"
mkdir -p "$ARCHIVE/lib/iOS-fat"
mkdir -p "$ARCHIVE/lib/MacOS"
mkdir -p "$ARCHIVE/lib/tvOS"
mkdir -p "$ARCHIVE/lib/tvOS-simulator"
if [ "$catalyst" != "" ]; then
mkdir -p "$ARCHIVE/lib/Catalyst"
fi
mkdir -p "$ARCHIVE/bin"
mkdir -p "$ARCHIVE/framework"
mkdir -p "$ARCHIVE/xcframework"
# libraries for libcurl, libcrypto and libssl
if [ "$BUILDFOR" == "ios" ] || [ "$BUILDFOR" == "all" ]; then
# Copy iOS libraries
cp curl/lib/libcurl_iOS.a $ARCHIVE/lib/iOS/libcurl.a
cp curl/lib/libcurl_iOS-simulator.a $ARCHIVE/lib/iOS-simulator/libcurl.a
cp curl/lib/libcurl_iOS-fat.a $ARCHIVE/lib/iOS-fat/libcurl.a
cp openssl/iOS/lib/libcrypto.a $ARCHIVE/lib/iOS/libcrypto.a
cp openssl/iOS-simulator/lib/libcrypto.a $ARCHIVE/lib/iOS-simulator/libcrypto.a
cp openssl/iOS-fat/lib/libcrypto.a $ARCHIVE/lib/iOS-fat/libcrypto.a
cp openssl/iOS/lib/libssl.a $ARCHIVE/lib/iOS/libssl.a
cp openssl/iOS-simulator/lib/libssl.a $ARCHIVE/lib/iOS-simulator/libssl.a
cp openssl/iOS-fat/lib/libssl.a $ARCHIVE/lib/iOS-fat/libssl.a
fi
if [ "$BUILDFOR" == "tvos" ] || [ "$BUILDFOR" == "all" ]; then
# Copy tvOS libraries
cp curl/lib/libcurl_tvOS.a $ARCHIVE/lib/tvOS/libcurl.a
cp curl/lib/libcurl_tvOS-simulator.a $ARCHIVE/lib/tvOS-simulator/libcurl.a
cp openssl/tvOS/lib/libcrypto.a $ARCHIVE/lib/tvOS/libcrypto.a
cp openssl/tvOS-simulator/lib/libcrypto.a $ARCHIVE/lib/tvOS-simulator/libcrypto.a
cp openssl/tvOS/lib/libssl.a $ARCHIVE/lib/tvOS/libssl.a
cp openssl/tvOS-simulator/lib/libssl.a $ARCHIVE/lib/tvOS-simulator/libssl.a
fi
if [ "$BUILDFOR" == "macos" ] || [ "$BUILDFOR" == "all" ]; then
# Copy MacOS libraries
cp curl/lib/libcurl_Mac.a $ARCHIVE/lib/MacOS/libcurl.a
cp openssl/Mac/lib/libcrypto.a $ARCHIVE/lib/MacOS/libcrypto.a
cp openssl/Mac/lib/libssl.a $ARCHIVE/lib/MacOS/libssl.a
fi
if [ "$catalyst" != "" ]; then
# Add catalyst libraries
cp curl/lib/libcurl_Catalyst.a $ARCHIVE/lib/Catalyst/libcurl.a
cp openssl/Catalyst/lib/libcrypto.a $ARCHIVE/lib/Catalyst/libcrypto.a
cp openssl/Catalyst/lib/libssl.a $ARCHIVE/lib/Catalyst/libssl.a
# Build XCFrameworks with Catalyst library
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/iOS-simulator/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/tvOS/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/tvOS-simulator/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/Catalyst/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/MacOS/libcurl.a \
-headers curl/include \
-output $ARCHIVE/xcframework/libcurl.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libcrypto.a \
-headers openssl/iOS/include \
-library $ARCHIVE/lib/iOS-simulator/libcrypto.a \
-headers openssl/iOS-simulator/include \
-library $ARCHIVE/lib/tvOS/libcrypto.a \
-headers openssl/tvOS/include \
-library $ARCHIVE/lib/tvOS-simulator/libcrypto.a \
-headers openssl/tvOS-simulator/include \
-library $ARCHIVE/lib/Catalyst/libcrypto.a \
-headers openssl/Mac/include \
-library $ARCHIVE/lib/MacOS/libcrypto.a \
-headers openssl/Mac/include \
-output $ARCHIVE/xcframework/libcrypto.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libssl.a \
-library $ARCHIVE/lib/iOS-simulator/libssl.a \
-library $ARCHIVE/lib/tvOS/libssl.a \
-library $ARCHIVE/lib/tvOS-simulator/libssl.a \
-library $ARCHIVE/lib/Catalyst/libssl.a \
-library $ARCHIVE/lib/MacOS/libssl.a \
-output $ARCHIVE/xcframework/libssl.xcframework
elif [ "$BUILDFOR" == "all" ]; then
# Build XCFrameworks
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/iOS-simulator/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/tvOS/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/tvOS-simulator/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/MacOS/libcurl.a \
-headers curl/include \
-output $ARCHIVE/xcframework/libcurl.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libcrypto.a \
-headers openssl/iOS/include \
-library $ARCHIVE/lib/iOS-simulator/libcrypto.a \
-headers openssl/iOS-simulator/include \
-library $ARCHIVE/lib/tvOS/libcrypto.a \
-headers openssl/tvOS/include \
-library $ARCHIVE/lib/tvOS-simulator/libcrypto.a \
-headers openssl/tvOS-simulator/include \
-library $ARCHIVE/lib/MacOS/libcrypto.a \
-headers openssl/Mac/include \
-output $ARCHIVE/xcframework/libcrypto.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libssl.a \
-library $ARCHIVE/lib/iOS-simulator/libssl.a \
-library $ARCHIVE/lib/tvOS/libssl.a \
-library $ARCHIVE/lib/tvOS-simulator/libssl.a \
-library $ARCHIVE/lib/MacOS/libssl.a \
-output $ARCHIVE/xcframework/libssl.xcframework
# openssl/openssl-ios-armv7_armv7s_arm64_arm64e.a
# openssl/openssl-ios-i386_x86_64_arm64-simulator.a
cp openssl/*.a $ARCHIVE/framework
elif [ "$BUILDFOR" == "ios" ]; then
# Build XCFrameworks
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/iOS-simulator/libcurl.a \
-headers curl/include \
-output $ARCHIVE/xcframework/libcurl.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libcrypto.a \
-headers openssl/iOS/include \
-library $ARCHIVE/lib/iOS-simulator/libcrypto.a \
-headers openssl/iOS-simulator/include \
-output $ARCHIVE/xcframework/libcrypto.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libssl.a \
-library $ARCHIVE/lib/iOS-simulator/libssl.a \
-output $ARCHIVE/xcframework/libssl.xcframework
# openssl/openssl-ios-armv7_armv7s_arm64_arm64e.a
# openssl/openssl-ios-i386_x86_64_arm64-simulator.a
cp openssl/*.a $ARCHIVE/framework
elif [ "$BUILDFOR" == "tvos" ]; then
# Build XCFrameworks
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/tvOS/libcurl.a \
-headers curl/include \
-library $ARCHIVE/lib/tvOS-simulator/libcurl.a \
-headers curl/include \
-output $ARCHIVE/xcframework/libcurl.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/tvOS/libcrypto.a \
-headers openssl/tvOS/include \
-library $ARCHIVE/lib/tvOS-simulator/libcrypto.a \
-headers openssl/tvOS-simulator/include \
-output $ARCHIVE/xcframework/libcrypto.xcframework
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/tvOS/libssl.a \
-library $ARCHIVE/lib/tvOS-simulator/libssl.a \
-output $ARCHIVE/xcframework/libssl.xcframework
elif [ "$BUILDFOR" == "macos" ]; then
# Build XCFrameworks
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/MacOS/libcurl.a \
-headers curl/include \
-output $ARCHIVE/xcframework/libcurl.xcframework
fi
# libraries for nghttp2
if [ "$buildnghttp2" != "" ]; then
# nghttp2 libraries
if [ "$BUILDFOR" == "ios" ] || [ "$BUILDFOR" == "all" ]; then
cp nghttp2/lib/libnghttp2_iOS.a $ARCHIVE/lib/iOS/libnghttp2.a
cp nghttp2/lib/libnghttp2_iOS-simulator.a $ARCHIVE/lib/iOS-simulator/libnghttp2.a
cp nghttp2/lib/libnghttp2_iOS-fat.a $ARCHIVE/lib/iOS-fat/libnghttp2.a
fi
if [ "$BUILDFOR" == "tvos" ] || [ "$BUILDFOR" == "all" ]; then
cp nghttp2/lib/libnghttp2_tvOS.a $ARCHIVE/lib/tvOS/libnghttp2.a
cp nghttp2/lib/libnghttp2_tvOS-simulator.a $ARCHIVE/lib/tvOS-simulator/libnghttp2.a
fi
if [ "$BUILDFOR" == "macos" ] || [ "$BUILDFOR" == "all" ]; then
cp nghttp2/lib/libnghttp2_Mac.a $ARCHIVE/lib/MacOS/libnghttp2.a
fi
if [ "$catalyst" != "" ]; then
cp nghttp2/lib/libnghttp2_Catalyst.a $ARCHIVE/lib/Catalyst/libnghttp2.a
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libnghttp2.a \
-library $ARCHIVE/lib/iOS-simulator/libnghttp2.a \
-library $ARCHIVE/lib/tvOS/libnghttp2.a \
-library $ARCHIVE/lib/tvOS-simulator/libnghttp2.a \
-library $ARCHIVE/lib/Catalyst/libnghttp2.a \
-library $ARCHIVE/lib/MacOS/libnghttp2.a \
-output $ARCHIVE/xcframework/libnghttp2.xcframework
elif [ "$BUILDFOR" == "macos" ]; then
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/MacOS/libnghttp2.a \
-output $ARCHIVE/xcframework/libnghttp2.xcframework
elif [ "$BUILDFOR" == "ios" ]; then
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libnghttp2.a \
-library $ARCHIVE/lib/iOS-simulator/libnghttp2.a \
-output $ARCHIVE/xcframework/libnghttp2.xcframework
elif [ "$BUILDFOR" == "tvos" ]; then
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/tvOS/libnghttp2.a \
-library $ARCHIVE/lib/tvOS-simulator/libnghttp2.a \
-output $ARCHIVE/xcframework/libnghttp2.xcframework
else # all
xcodebuild -create-xcframework \
-library $ARCHIVE/lib/iOS/libnghttp2.a \
-library $ARCHIVE/lib/iOS-simulator/libnghttp2.a \
-library $ARCHIVE/lib/tvOS/libnghttp2.a \
-library $ARCHIVE/lib/tvOS-simulator/libnghttp2.a \
-library $ARCHIVE/lib/MacOS/libnghttp2.a \
-output $ARCHIVE/xcframework/libnghttp2.xcframework
fi
fi
# archive header files
if [ "$BUILDFOR" == "ios" ] || [ "$BUILDFOR" == "all" ]; then
cp openssl/iOS/include/openssl/* "$ARCHIVE/include/openssl"
elif [ "$BUILDFOR" == "tvos" ]; then
cp openssl/tvOS/include/openssl/* "$ARCHIVE/include/openssl"
elif [ "$BUILDFOR" == "macos" ]; then
cp openssl/Mac/include/openssl/* "$ARCHIVE/include/openssl"
fi
cp curl/include/curl/* "$ARCHIVE/include/curl"
# grab root certs
curl -sL https://curl.se/ca/cacert.pem > $ARCHIVE/cacert.pem
# create README for archive
sed -e "s/ZZZCMDS/$BUILD_CMD/g" -e "s/ZZZLIBCURL/$LIBCURL/g" -e "s/ZZZOPENSSL/$OPENSSL/g" -e "s/ZZZNGHTTP2/$NGHTTP2/g" archive/release-template.md > $ARCHIVE/README.md
echo
# EXAMPLE iOS and tvOS App - update test app with latest includes and XCFrameworks
echo -e "${bold}Copying libraries to Test Apps ...${dim}"
if [[ "$BUILDFOR" == "all" ]]; then
EXAMPLES=("example/iOS Test App" "example/tvOS Test App" "example/macOS Test App")
elif [[ "$BUILDFOR" == "ios" ]]; then
EXAMPLES=("example/iOS Test App")
elif [[ "$BUILDFOR" == "tvos" ]]; then
EXAMPLES=("example/tvOS Test App")
elif [[ "$BUILDFOR" == "macos" ]]; then
EXAMPLES=("example/macOS Test App")
fi
for EXAMPLE in "${EXAMPLES[@]}"; do
echo " Upating: $EXAMPLE"
# Create necessary directories
mkdir -p "$EXAMPLE/libs" "$EXAMPLE/include/curl" "$EXAMPLE/include/openssl"
# Copy includes
if [[ "$EXAMPLE" == *"macOS"* ]]; then
cp openssl/Mac/include/openssl/* "$EXAMPLE/include/openssl/"
elif [[ "$EXAMPLE" == *"iOS"* ]]; then
cp openssl/iOS/include/openssl/* "$EXAMPLE/include/openssl/"
elif [[ "$EXAMPLE" == *"tvOS"* ]]; then
cp openssl/tvOS/include/openssl/* "$EXAMPLE/include/openssl/"
fi
cp curl/include/curl/* "$EXAMPLE/include/curl/"
# Copy certificate bundle
cp $ARCHIVE/cacert.pem "$EXAMPLE/cacert.pem"
# Copy XCFrameworks
cp -R $ARCHIVE/xcframework/*.xcframework "$EXAMPLE/libs/"
done
echo
# Create universal Mac binaries and run test
if [ "$BUILDFOR" == "macos" ] || [ "$BUILDFOR" == "all" ]; then
echo -e "${bold}Archiving Mac binaries for curl and openssl...${dim}"
echo " See $ARCHIVE/bin"
lipo -create -output $ARCHIVE/bin/curl /tmp/curl-x86_64 /tmp/curl-arm64
mv /tmp/curl-* $ARCHIVE/bin
lipo -create -output $ARCHIVE/bin/openssl /tmp/openssl-x86_64 /tmp/openssl-arm64
mv /tmp/openssl-* $ARCHIVE/bin
echo
echo -e "${bold}Testing Universal Mac binaries for ${BUILD_MACHINE}...${dim}"
echo -e " ${bold}cURL${dim}"
file $ARCHIVE/bin/curl
$ARCHIVE/bin/curl -V
echo -e " ${bold}OpenSSL${dim}"
file $ARCHIVE/bin/openssl
$ARCHIVE/bin/openssl version
fi
## Done - Display Build Duration
echo
echo -e "${bold}Build Complete${dim}"
date "+ %c - End"
END=$(date +%s)
secs=$(echo "$END - $START" | bc)
printf ' Duration %02dh:%02dm:%02ds\n' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))
echo -e "${normal}"
rm -f $NOHTTP2