-
Notifications
You must be signed in to change notification settings - Fork 3
/
boost.sh
executable file
·1757 lines (1517 loc) · 55.9 KB
/
boost.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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for iOS, iOS Simulator, tvOS, tvOS Simulator, and macOS.
# Creates a set of universal libraries that can be used on an iOS and in the
# iOS simulator. Then creates a pseudo-framework to make using boost in Xcode
# less painful.
#
# To configure the script, define:
# BOOST_VERSION: Which version of Boost to build (e.g. 1.69.0)
# BOOST_LIBS: Which Boost libraries to build
# IOS_SDK_VERSION: iOS SDK version (e.g. 12.0)
# MIN_IOS_VERSION: Minimum iOS Target Version (e.g. 11.0)
# TVOS_SDK_VERSION: iOS SDK version (e.g. 12.0)
# MIN_TVOS_VERSION: Minimum iOS Target Version (e.g. 11.0)
# MACOS_SDK_VERSION: macOS SDK version (e.g. 10.14)
# MIN_MACOS_VERSION: Minimum macOS Target Version (e.g. 10.12)
# MACOS_SILICON_SDK_VERSION: macOS SDK version for Apple Silicon (e.g. 11.0)
# MIN_MACOS_SILICON_VERSION: Minimum macOS Target Version for Apple Silicon (e.g. 11.0)
# MAC_CATALYST_SDK_VERSION: macOS SDK version when building a Mac Catalyst app (e.g. 10.15)
# MIN_MAC_CATALYST_VERSION: Minimum iOS Target Version when building a Mac Catalyst app (e.g. 13.0)
#
# If a boost tarball (a file named “boost_$BOOST_VERSION_SNAKE_CASE.tar.bz2”) does not
# exist in the current directory, this script will attempt to download the
# version specified. You may also manually place a matching
# tarball in the current directory and the script will use that.
#
#===============================================================================
BOOST_VERSION=1.76.0
BOOST_LIBS=("atomic" "chrono" "date_time" "exception" "filesystem"
"program_options" "random" "system" "thread" "test")
ALL_BOOST_LIBS_1_68=("atomic" "chrono" "container" "context" "coroutine"
"coroutine2" "date_time" "exception" "fiber" "filesystem" "graph"
"graph_parallel" "iostreams" "locale" "log" "math" "metaparse" "mpi"
"program_options" "python" "random" "regex" "serialization" "signals" "system"
"test" "thread" "timer" "type_erasure" "wave")
ALL_BOOST_LIBS_1_69=("atomic" "chrono" "container" "context" "coroutine"
"coroutine2" "date_time" "exception" "fiber" "filesystem" "graph"
"graph_parallel" "iostreams" "locale" "log" "math" "metaparse" "mpi"
"program_options" "python" "random" "regex" "serialization" "signals2" "system"
"test" "thread" "timer" "type_erasure" "wave")
BOOTSTRAP_LIBS=()
MIN_IOS_VERSION=11.0
MIN_TVOS_VERSION=11.0
MIN_MACOS_VERSION=10.12
MIN_MACOS_SILICON_VERSION=11
MACOS_SDK_VERSION=$(xcrun --sdk macosx --show-sdk-version)
MACOS_SDK_PATH=$(xcrun --sdk macosx --show-sdk-path)
MIN_MAC_CATALYST_VERSION=13.0
MACOS_ARCHS=("i386" "x86_64")
MACOS_SILICON_ARCHS=("arm64")
IOS_ARCHS=("armv7" "arm64")
IOS_SIM_ARCHS=("i386" "x86_64" "arm64")
TVOS_ARCHS=("arm64")
TVOS_SIM_ARCHS=("x86_64" "arm64")
MAC_CATALYST_ARCHS=("x86_64")
# Applied to all platforms
CXX_FLAGS=""
LD_FLAGS=""
OTHER_FLAGS="-std=c++14 -stdlib=libc++ -DNDEBUG"
XCODE_VERSION=$(xcrun xcodebuild -version | head -n1 | tr -Cd '[:digit:].')
XCODE_ROOT=$(xcode-select -print-path)
COMPILER="$XCODE_ROOT/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
THREADS="-j$(sysctl -n hw.ncpu)"
CURRENT_DIR=$(pwd)
SRCDIR="$CURRENT_DIR/src"
IOS_DEV_CMD="xcrun --sdk iphoneos"
IOS_SIM_DEV_CMD="xcrun --sdk iphonesimulator"
TVOS_DEV_CMD="xcrun --sdk appletvos"
TVOS_SIM_DEV_CMD="xcrun --sdk appletvsimulator"
MACOS_DEV_CMD="xcrun --sdk macosx"
MACOS_SILICON_DEV_CMD="xcrun --sdk macosx"
MAC_CATALYST_DEV_CMD="xcrun --sdk macosx"
BUILD_VARIANT=release
#===============================================================================
# Functions
#===============================================================================
sdkVersion()
{
FULL_VERSION=$(xcrun --sdk "$1" --show-sdk-version)
read -ra VERSION <<< "${FULL_VERSION//./ }"
echo "${VERSION[0]}.${VERSION[1]}"
}
IOS_SDK_VERSION=$(sdkVersion iphoneos)
TVOS_SDK_VERSION=$(sdkVersion appletvos)
MACOS_SDK_VERSION=$(sdkVersion macosx)
MACOS_SILICON_SDK_VERSION=$(sdkVersion macosx)
MAC_CATALYST_SDK_VERSION=$(sdkVersion macosx)
sdkPath()
{
xcrun --sdk "$1" --show-sdk-path
}
IOS_SDK_PATH=$(sdkPath iphoneos)
IOSSIM_SDK_PATH=$(sdkPath iphonesimulator)
TVOS_SDK_PATH=$(sdkPath appletvos)
TVOSSIM_SDK_PATH=$(sdkPath appletvsimulator)
MACOS_SDK_PATH=$(sdkPath macosx)
MAC_CATALYST_SDK_PATH=$(sdkPath macosx)
MACOS_SILICON_SDK_PATH=$(sdkPath macosx)
usage()
{
cat << EOF
usage: $0 [{-ios,-tvos,-macos} ...] options
Build Boost for iOS, iOS Simulator, tvOS, tvOS Simulator, and macOS
The -ios, -tvos, and -macOS options may be specified together. Default
is to build all of them.
Examples:
./boost.sh -ios -tvos --boost-version 1.68.0
./boost.sh -macos --no-framework
./boost.sh --clean
OPTIONS:
-h | --help
Display these options and exit.
-ios
Build for the iOS platform.
-macos
Build for the macOS platform.
-tvos
Build for the tvOS platform.
-mac-catalyst
Build for the Mac Catalyst platform (UIKit on Mac).
--boost-version [num]
Specify which version of Boost to build.
Defaults to $BOOST_VERSION.
--boost-libs "{all|none|(lib, ...)}"
Specify which libraries to build. Space-separate list. Pass 'all' to
build all optional libraries. Pass 'none' to skip building optional
libraries.
Defaults to: ${BOOST_LIBS[@]}
Boost libraries requiring separate building are:
- atomic
- chrono
- container (Unavailable on tvOS)
- context (macOS only)
- coroutine (macOS only)
- coroutine2 (macOS only)
- date_time
- exception
- fiber (No complaints when building for iOS / tvOS, but no library is output)
- filesystem
- graph
- graph_parallel (No complaints when building for iOS / tvOS, but no library is output)
- iostreams
- locale
- log
- math (Unavailable* on iOS, tvOS)
- metaparse (Unavailable on tvOS)
- mpi (macOS only. Requires mpic++ (openmpi))
- program_options
- python
- random
- regex
- serialization
- signals
- system
- test (Unavailable on tvOS)
- thread
- timer
- type_erasure
- wave
NOTE:
Unsupported and unavailable libraries are ignored when building for the
platforms they are unsupported on. It's OK to pass them as arguments,
just be aware that they will not be built for those platforms.
Several libraries are unavailable on tvOS only because they make calls
that are not available in tvOS.
There are a couple of libraries that *appear* to build successfully for
iOS and / or tvOS, but there is no library output, so I don't know that
they are actually built for those platforms. I don't use them so I can't
say for certain. If you find out one way or the other, please let me
know so I can update this.
* math fails for iOS and tvOS with a complaint about using a PCH with
multiple architectures defined. I don't know how to get around this if
you need a specific architecture (like arm64), since the only RISC
option for the <architeciture> jamfile feature tag is 'arm'. I'm sure
there's a way to get this working by tweaking user-config, but I haven't
the time to figure it out now.
--ios-sdk [num]
Specify the iOS SDK version to build with.
Defaults to $IOS_SDK_VERSION
--min-ios-version [num]
Specify the minimum iOS version to target. Since iOS 11+ are 64-bit only,
if the minimum iOS version is set to iOS 11.0 or later, iOS archs is
automatically set to 'arm64' and iOS Simulator archs is set to ("x86_64"
"arm64") unless '--ios-archs' is also specified.
Defaults to $MIN_IOS_VERSION
--ios-archs "(archs, ...)"
Specify the iOS architectures to build for. Also updates the iOS Simulator
architectures to match. Space-separate list.
--tvos-sdk [num]
Specify the tvOS SDK version to build with.
Defaults to $TVOS_SDK_VERSION
--min-tvos_version [num]
Specify the minimum tvOS version to target.
Defaults to $MIN_TVOS_VERSION
--macos-sdk [num]
Specify the macOS SDK version to build with.
Defaults to $MACOS_SDK_VERSION
--macos-silicon-sdk
Specify the macOS SDK version to build Apple Silicon binaries with.
Defaults to $MACOS_SILICON_SDK_VERSION
--min-macos-version [num]
Specify the minimum macOS version to target.
Defaults to $MIN_MACOS_VERSION
--min-macos-silicon-version [NUM]
Specify the minimum macOS Apple Silicon version to target.
Defaults to $MIN_MACOS_SILICON_VERSION
--macos-archs "(archs, ...)"
Specify the macOS architectures to build for. Space-separate list.
Defaults to ${MACOS_ARCHS[*]}
--macos-silicon-archs "(archs, ...)"
Specify the macOS Apple Silicon architectures to build for. Space-separate list.
Defaults to ${MACOS_SILICON_ARCHS[*]}
--mac-catalyst-sdk [num]
Specify the macOS SDK version to build the Mac Catalyst slice with.
Defaults to $MAC_CATALYST_SDK_VERSION
--min-mac-catalyst-version [num]
Specify the minimum iOS version to target for the Mac Catalyst slice.
Defaults to $MIN_MAC_CATALYST_VERSION
--mac-catalyst-archs "(archs, ...)"
Specify the Mac Catalyst architectures to build for. Space-separate list.
Defaults to ${MAC_CATALYST_ARCHS[*]}
--hidden-visibility
Compile using -fvisibility=hidden and -fvisibility-inlines-hidden
--no-framework
Do not create the xcframework.
--universal
Create universal FAT binary.
--debug
Build a debug variant.
--clean
Just clean up build artifacts, but don't actually build anything.
(all other parameters are ignored)
--purge
Removes everything (build directory, src, Boost tarball, etc.).
Similar to --clean, but more thorough.
--no-clean
Do not clean up existing build artifacts before building.
-j | --threads [num]
Specify the number of threads to use.
Defaults to $THREADS
EOF
}
abort()
{
echo
echo "Aborted:" "$@"
exit 1
}
die()
{
usage
exit 1
}
cd_or_abort()
{
cd "$1" || abort "Could not change directory into \"$1\""
}
missingParameter()
{
echo "$1 requires a parameter"
die
}
unknownParameter()
{
if [[ -n $2 && $2 != "" ]]; then
echo "Unknown argument \"$2\" for parameter $1."
else
echo "Unknown argument $1"
fi
die
}
parseArgs()
{
while [ "$1" != "" ]; do
case $1 in
-h | --help)
usage
exit
;;
-ios)
BUILD_IOS=1
;;
-tvos)
BUILD_TVOS=1
;;
-macos)
BUILD_MACOS=1
;;
-macossilicon)
BUILD_MACOS_SILICON=1
;;
-mac-catalyst)
BUILD_MAC_CATALYST=1
;;
--boost-version)
if [ -n "$2" ]; then
BOOST_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--boost-libs)
if [ -n "$2" ]; then
CUSTOM_LIBS=$2
shift
else
missingParameter "$1"
fi
;;
--ios-sdk)
if [ -n "$2" ]; then
IOS_SDK_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--min-ios-version)
if [ -n "$2" ]; then
MIN_IOS_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--ios-archs)
if [ -n "$2" ]; then
CUSTOM_IOS_ARCHS=$2
shift;
else
missingParameter "$1"
fi
;;
--tvos-sdk)
if [ -n "$2" ]; then
TVOS_SDK_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--min-tvos-version)
if [ -n "$2" ]; then
MIN_TVOS_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--macos-sdk)
if [ -n "$2" ]; then
MACOS_SDK_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--macos-silicon-sdk)
if [ -n "$2" ]; then
MACOS_SILICON_SDK_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--min-macos-version)
if [ -n "$2" ]; then
MIN_MACOS_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--min-macos-silicon-version)
if [ -n "$2" ]; then
MIN_MACOS_SILICON_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--macos-archs)
if [ -n "$2" ]; then
CUSTOM_MACOS_ARCHS=$2
shift;
else
missingParameter "$1"
fi
;;
--macos-silicon-archs)
if [ -n "$2" ]; then
CUSTOM_MACOS_SILICON_ARCHS=$2
shift;
else
missingParameter "$1"
fi
;;
--mac-catalyst-sdk)
if [ -n "$2" ]; then
MAC_CATALYST_SDK_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--min-mac-catalyst-version)
if [ -n "$2" ]; then
MIN_MAC_CATALYST_VERSION=$2
shift
else
missingParameter "$1"
fi
;;
--mac-catalyst-archs)
if [ -n "$2" ]; then
CUSTOM_MAC_CATALYST_ARCHS=$2
shift;
else
missingParameter "$1"
fi
;;
--hidden-visibility)
CXX_FLAGS="$CXX_FLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
;;
--universal)
UNIVERSAL=1
;;
--debug)
BUILD_VARIANT=debug
;;
--clean)
CLEAN=1
;;
--purge)
PURGE=1
;;
--no-clean)
NO_CLEAN=1
;;
--no-framework)
NO_FRAMEWORK=1
;;
-j | --threads)
if [ -n "$2" ]; then
THREADS="-j$2"
shift
else
missingParameter "$1"
fi
;;
*)
unknownParameter "$1"
;;
esac
shift
done
if [[ -n $CUSTOM_LIBS ]]; then
if [[ "$CUSTOM_LIBS" == "none" ]]; then
BOOST_LIBS=()
elif [[ "$CUSTOM_LIBS" == "all" ]]; then
read -ra BOOST_PARTS <<< "${BOOST_VERSION//./ }"
if [[ ${BOOST_PARTS[1]} -lt 69 ]]; then
BOOST_LIBS=("${ALL_BOOST_LIBS_1_68[@]}")
else
BOOST_LIBS=("${ALL_BOOST_LIBS_1_69[@]}")
fi
else
read -ra BOOST_LIBS <<< "$CUSTOM_LIBS"
fi
fi
# Force 32/64-bit architecture when building universal macOS.
# Forcing i386 & x86_64 is fine for now, but if macOS ever supports
# other architectures in the future we'll need to be a bit smarter
# about this.
if [[ -n $BUILD_MACOS && -n $UNIVERSAL ]]; then
CUSTOM_MACOS_ARCHS=("i386 x86_64")
fi
if [[ "${#CUSTOM_MACOS_ARCHS[@]}" -gt 0 ]]; then
read -ra MACOS_ARCHS <<< "${CUSTOM_MACOS_ARCHS[@]}"
fi
if [[ "${#CUSTOM_MACOS_SILICON_ARCHS[@]}" -gt 0 ]]; then
read -ra MACOS_SILICON_ARCHS <<< "${CUSTOM_MACOS_SILICON_ARCHS[@]}"
fi
if [[ "${#CUSTOM_MAC_CATALYST_ARCHS[@]}" -gt 0 ]]; then
read -ra MAC_CATALYST_ARCHS <<< "${CUSTOM_MAC_CATALYST_ARCHS[@]}"
fi
if [[ "${#CUSTOM_IOS_ARCHS[@]}" -gt 0 ]]; then
read -ra IOS_ARCHS <<< "${CUSTOM_IOS_ARCHS[@]}"
IOS_SIM_ARCHS=()
# As of right now this matches the currently available ARM architectures
# Add 32-bit simulator for 32-bit arm
if [[ "${IOS_ARCHS[*]}" =~ armv ]]; then
IOS_SIM_ARCHS+=("i386")
fi
# Add x86-64 and arm64 mac simulator for 64-bit arm iOS
if [[ "${IOS_ARCHS[*]}" =~ arm64 ]]; then
IOS_SIM_ARCHS+=("x86_64" "arm64")
fi
else
read -ra MIN_IOS_PARTS <<< "${MIN_IOS_VERSION//./ }"
if [[ ${MIN_IOS_PARTS[0]} -ge 11 ]]; then
# iOS 11 dropped support for 32bit devices
IOS_ARCHS=("arm64")
IOS_SIM_ARCHS=("x86_64" "arm64")
fi
fi
}
doneSection()
{
echo
echo "Done"
echo "================================================================="
echo
}
#===============================================================================
cleanup()
{
echo Cleaning everything
if [[ -n $BUILD_IOS ]]; then
rm -rf "$BOOST_SRC/iphone-build"
rm -rf "$BOOST_SRC/iphonesim-build"
rm -rf "$IOS_OUTPUT_DIR"
fi
if [[ -n $BUILD_TVOS ]]; then
rm -rf "$BOOST_SRC/appletv-build"
rm -rf "$BOOST_SRC/appletvsim-build"
rm -rf "$TVOS_OUTPUT_DIR"
fi
if [[ -n $BUILD_MACOS ]]; then
rm -rf "$BOOST_SRC/macos-build"
rm -rf "$MACOS_OUTPUT_DIR"
fi
if [[ -n $BUILD_MACOS_SILICON ]]; then
rm -rf "$BOOST_SRC/macos-silicon-build"
rm -rf "$MACOS_SILICON_OUTPUT_DIR"
fi
if [[ -n $BUILD_MACOS ]] || [[ -n $BUILD_MACOS_SILICON ]] ; then
rm -rf "$MACOS_COMBINED_OUTPUT_DIR"
fi
if [[ -n $BUILD_MAC_CATALYST ]]; then
rm -rf "$BOOST_SRC/mac-catalyst-build"
rm -rf "$MAC_CATALYST_OUTPUT_DIR"
fi
doneSection
}
#===============================================================================
# version() from https://stackoverflow.com/a/37939589/3938401
version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
downloadBoost()
{
if [ "$(version "$BOOST_VERSION")" -ge "$(version "1.63.0")" ]; then
DOWNLOAD_SRC=https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_SNAKE_CASE}.tar.bz2
else
DOWNLOAD_SRC=http://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_SNAKE_CASE}.tar.bz2/download
fi
if [ ! -s "$BOOST_TARBALL" ]; then
echo "Downloading boost ${BOOST_VERSION} from ${DOWNLOAD_SRC}"
curl -L -o "$BOOST_TARBALL" "$DOWNLOAD_SRC"
doneSection
fi
}
#===============================================================================
unpackBoost()
{
[ -f "$BOOST_TARBALL" ] || abort "Source tarball missing."
echo Unpacking boost into "$SRCDIR"...
[ -d "$SRCDIR" ] || mkdir -p "$SRCDIR"
[ -d "$BOOST_SRC" ] || ( cd_or_abort "$SRCDIR"; tar xjf "$BOOST_TARBALL" )
[ -d "$BOOST_SRC" ] && echo " ...unpacked as $BOOST_SRC"
doneSection
}
#===============================================================================
patchBoost()
{
if [ "$(version "$BOOST_VERSION")" -le "$(version "1.73.0")" ] &&
[ "$(version "$XCODE_VERSION")" -ge "$(version "11.4")" ]
then
echo "Patching boost in $BOOST_SRC"
# https://github.com/boostorg/build/pull/560
(cd "$BOOST_SRC" && patch --forward -p1 -d "$BOOST_SRC/tools/build" < "$CURRENT_DIR/patches/xcode-11.4.patch")
doneSection
fi
}
#===============================================================================
copyMissingHeaders()
{
# These files are missing in the ARM iPhoneOS SDK, but they are in the simulator.
# They are supported on the device, so we copy them from x86 SDK to a staging area
# to use them on ARM, too.
echo "Inventing missing headers"
cp "$XCODE_ROOT/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator${IOS_SDK_VERSION}.sdk/usr/include/"{crt_externs,bzlib}.h "$BOOST_SRC"
doneSection
}
#===============================================================================
updateBoostUserConfigJam()
{
echo "Updating boost into $BOOST_SRC..."
USING_MPI=
if [[ "${BOOST_LIBS[*]}" =~ "mpi" ]]; then
USING_MPI="using mpi ;" # trailing space needed
fi
cat > "$BOOST_SRC/tools/build/src/user-config.jam" <<EOF
using darwin : $COMPILER_VERSION~iphone
: $COMPILER
: <architecture>arm
<target-os>iphone
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${IOS_ARCH_FLAGS[*]} $EXTRA_IOS_FLAGS -isysroot $IOS_SDK_PATH"
<threading>multi
;
using darwin : $COMPILER_VERSION~iphonesim
: $COMPILER
: <architecture>x86
<target-os>iphone
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${IOS_SIM_ARCH_FLAGS[*]} $EXTRA_IOS_SIM_FLAGS -isysroot $IOSSIM_SDK_PATH"
<threading>multi
;
using darwin : $COMPILER_VERSION~appletv
: $COMPILER
: <architecture>arm
<target-os>iphone
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${TVOS_ARCH_FLAGS[*]} $EXTRA_TVOS_FLAGS -isysroot $TVOS_SDK_PATH"
<threading>multi
;
using darwin : $COMPILER_VERSION~appletvsim
: $COMPILER
: <architecture>x86
<target-os>iphone
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${TVOS_SIM_ARCH_FLAGS[*]} $EXTRA_TVOS_SIM_FLAGS -isysroot $TVOSSIM_SDK_PATH"
<threading>multi
;
using darwin : $COMPILER_VERSION~macos
: $COMPILER
: <architecture>x86
<target-os>darwin
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${MACOS_ARCH_FLAGS[*]} $EXTRA_MACOS_FLAGS -isysroot $MACOS_SDK_PATH"
<threading>multi
;
using darwin : $COMPILER_VERSION~macossilicon
: $COMPILER
: <architecture>arm
<target-os>darwin
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${MACOS_SILICON_ARCH_FLAGS[*]} $EXTRA_MACOS_SILICON_FLAGS -isysroot $MACOS_SILICON_SDK_PATH" -target arm64-apple-macos$MIN_MACOS_SILICON_VERSION
;
using darwin : $COMPILER_VERSION~maccatalyst
: $COMPILER
: <architecture>x86
<target-os>darwin
<cxxflags>"$CXX_FLAGS"
<linkflags>"$LD_FLAGS"
<compileflags>"$OTHER_FLAGS ${MAC_CATALYST_ARCH_FLAGS[*]} $EXTRA_MAC_CATALYST_FLAGS -isysroot $MAC_CATALYST_SDK_PATH -target x86_64-apple-ios$MIN_MAC_CATALYST_VERSION-macabi"
<threading>multi
;
$USING_MPI
EOF
doneSection
}
#===============================================================================
bootstrapBoost()
{
cd_or_abort "$BOOST_SRC"
if [[ ${#BOOST_LIBS[@]} -eq 0 ]]; then
ALL_BOOST_LIBS_COMMA=$(IFS=, ; echo "${ALL_BOOST_LIBS[*]}")
./bootstrap.sh --without-libraries="$ALL_BOOST_LIBS_COMMA"
else
BOOTSTRAP_LIBS=("${BOOST_LIBS[@]}")
# Strip out unsupported / unavailable libraries
if [[ "$1" == "iOS" ]]; then
UNSUPPORTED_LIBS=("context" "coroutine" "coroutine2" "math" "mpi")
for LIB in "${UNSUPPORTED_LIBS[@]}"; do
BOOTSTRAP_LIBS=("${BOOTSTRAP_LIBS[@]/$LIB}")
done
fi
if [[ "$1" == "tvOS" ]]; then
UNSUPPORTED_LIBS=("container" "context" "coroutine" "coroutine2"
"math" "metaparse" "mpi" "test")
for LIB in "${UNSUPPORTED_LIBS[@]}"; do
BOOTSTRAP_LIBS=("${BOOTSTRAP_LIBS[@]/$LIB}")
done
fi
echo "Bootstrap libs" "${BOOTSTRAP_LIBS[@]}"
BOOST_LIBS_COMMA=$(IFS=, ; echo "${BOOTSTRAP_LIBS[*]}")
echo "Bootstrapping for $1 (with libs $BOOST_LIBS_COMMA)"
./bootstrap.sh --with-libraries="$BOOST_LIBS_COMMA"
fi
doneSection
}
#===============================================================================
buildBoost_iOS()
{
cd_or_abort "$BOOST_SRC"
mkdir -p "$IOS_OUTPUT_DIR"
echo Building Boost for iPhone
# Install this one so we can copy the headers for the frameworks...
./b2 "$THREADS" \
--build-dir=iphone-build \
--stagedir=iphone-build/stage \
--prefix="$IOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~iphone" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${IOS_OUTPUT_DIR}/ios-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging iPhone. Check log."; exit 1; fi
./b2 "$THREADS" \
--build-dir=iphone-build \
--stagedir=iphone-build/stage \
--prefix="$IOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~iphone" \
link=static \
variant=${BUILD_VARIANT} \
install >> "${IOS_OUTPUT_DIR}/ios-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error installing iPhone. Check log."; exit 1; fi
doneSection
echo Building Boost for iPhoneSimulator
./b2 "$THREADS" \
--build-dir=iphonesim-build \
--stagedir=iphonesim-build/stage \
toolset="darwin-$COMPILER_VERSION~iphonesim" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${IOS_OUTPUT_DIR}/ios-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging iPhoneSimulator. Check log."; exit 1; fi
doneSection
}
buildBoost_tvOS()
{
cd_or_abort "$BOOST_SRC"
mkdir -p "$TVOS_OUTPUT_DIR"
echo Building Boost for AppleTV
./b2 "$THREADS" \
--build-dir=appletv-build \
--stagedir=appletv-build/stage \
--prefix="$TVOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~appletv" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${TVOS_OUTPUT_DIR}/tvos-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging AppleTV. Check log."; exit 1; fi
./b2 "$THREADS" \
--build-dir=appletv-build \
--stagedir=appletv-build/stage \
--prefix="$TVOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~appletv" \
link=static \
variant=${BUILD_VARIANT} \
install >> "${TVOS_OUTPUT_DIR}/tvos-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error installing AppleTV. Check log."; exit 1; fi
doneSection
echo "Building Boost for AppleTVSimulator"
./b2 "$THREADS" \
--build-dir=appletvsim-build \
--stagedir=appletvsim-build/stage \
--prefix="$TVOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~appletvsim" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${TVOS_OUTPUT_DIR}/tvos-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging AppleTVSimulator. Check log."; exit 1; fi
doneSection
}
buildBoost_macOS()
{
cd_or_abort "$BOOST_SRC"
mkdir -p "$MACOS_OUTPUT_DIR"
echo building Boost for macOS
./b2 "$THREADS" \
--build-dir=macos-build \
--stagedir=macos-build/stage \
--prefix="$MACOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~macos" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${MACOS_OUTPUT_DIR}/macos-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging macOS. Check log."; exit 1; fi
./b2 "$THREADS" \
--build-dir=macos-build \
--stagedir=macos-build/stage \
--prefix="$MACOS_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~macos" \
link=static \
variant=${BUILD_VARIANT} \
install >> "${MACOS_OUTPUT_DIR}/macos-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error installing macOS. Check log."; exit 1; fi
doneSection
}
buildBoost_macOS_silicon()
{
cd_or_abort "$BOOST_SRC"
mkdir -p "$MACOS_SILICON_OUTPUT_DIR"
echo building Boost for macOS Silicon
./b2 "$THREADS" \
--build-dir=macos-silicon-build \
--stagedir=macos-silicon-build/stage \
--prefix="$MACOS_SILICON_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~macossilicon" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${MACOS_SILICON_OUTPUT_DIR}/macos-silicon-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging macOS silicon. Check log."; exit 1; fi
./b2 "$THREADS" \
--build-dir=macos-silicon-build \
--stagedir=macos-silicon-build/stage \
--prefix="$MACOS_SILICON_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~macossilicon" \
link=static \
variant=${BUILD_VARIANT} \
install >> "${MACOS_SILICON_OUTPUT_DIR}/macos-silicon-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error installing macOS silicon. Check log."; exit 1; fi
}
buildBoost_mac_catalyst()
{
cd_or_abort "$BOOST_SRC"
mkdir -p "$MAC_CATALYST_OUTPUT_DIR"
echo Building Boost for Mac Catalyst
# Install this one so we can copy the headers for the frameworks...
./b2 "$THREADS" \
--build-dir=mac-catalyst-build \
--stagedir=mac-catalyst-build/stage \
--prefix="$MAC_CATALYST_OUTPUT_DIR/prefix" \
toolset="darwin-$COMPILER_VERSION~maccatalyst" \
link=static \
variant=${BUILD_VARIANT} \
stage >> "${MAC_CATALYST_OUTPUT_DIR}/mac-catalyst-build.log" 2>&1
# shellcheck disable=SC2181
if [ $? != 0 ]; then echo "Error staging Mac Catalyst. Check log."; exit 1; fi
./b2 "$THREADS" \