Skip to content

Commit 1e3a765

Browse files
Convert *BOOST_LIBS* variables as arrays
1 parent 9167e9a commit 1e3a765

File tree

1 file changed

+45
-44
lines changed

1 file changed

+45
-44
lines changed

boost.sh

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@
3535

3636
BOOST_VERSION=1.76.0
3737

38-
BOOST_LIBS="atomic chrono date_time exception filesystem program_options random system thread test"
39-
ALL_BOOST_LIBS_1_68="atomic chrono container context coroutine coroutine2
40-
date_time exception fiber filesystem graph graph_parallel iostreams locale log
41-
math metaparse mpi program_options python random regex serialization signals
42-
system test thread timer type_erasure wave"
43-
ALL_BOOST_LIBS_1_69="atomic chrono container context coroutine coroutine2
44-
date_time exception fiber filesystem graph graph_parallel iostreams locale log
45-
math metaparse mpi program_options python random regex serialization signals2
46-
system test thread timer type_erasure wave"
47-
BOOTSTRAP_LIBS=""
38+
BOOST_LIBS=("atomic" "chrono" "date_time" "exception" "filesystem"
39+
"program_options" "random" "system" "thread" "test")
40+
ALL_BOOST_LIBS_1_68=("atomic" "chrono" "container" "context" "coroutine"
41+
"coroutine2" "date_time" "exception" "fiber" "filesystem" "graph"
42+
"graph_parallel" "iostreams" "locale" "log" "math" "metaparse" "mpi"
43+
"program_options" "python" "random" "regex" "serialization" "signals" "system"
44+
"test" "thread" "timer" "type_erasure" "wave")
45+
ALL_BOOST_LIBS_1_69=("atomic" "chrono" "container" "context" "coroutine"
46+
"coroutine2" "date_time" "exception" "fiber" "filesystem" "graph"
47+
"graph_parallel" "iostreams" "locale" "log" "math" "metaparse" "mpi"
48+
"program_options" "python" "random" "regex" "serialization" "signals2" "system"
49+
"test" "thread" "timer" "type_erasure" "wave")
50+
BOOTSTRAP_LIBS=()
4851

4952
MIN_IOS_VERSION=11.0
5053
MIN_TVOS_VERSION=11.0
@@ -153,7 +156,7 @@ OPTIONS:
153156
Specify which libraries to build. Space-separate list. Pass 'all' to
154157
build all optional libraries. Pass 'none' to skip building optional
155158
libraries.
156-
Defaults to: $BOOST_LIBS
159+
Defaults to: ${BOOST_LIBS[@]}
157160
158161
Boost libraries requiring separate building are:
159162
- atomic
@@ -549,16 +552,17 @@ parseArgs()
549552

550553
if [[ -n $CUSTOM_LIBS ]]; then
551554
if [[ "$CUSTOM_LIBS" == "none" ]]; then
552-
CUSTOM_LIBS=""
555+
BOOST_LIBS=()
553556
elif [[ "$CUSTOM_LIBS" == "all" ]]; then
554557
read -ra BOOST_PARTS <<< "${BOOST_VERSION//./ }"
555558
if [[ ${BOOST_PARTS[1]} -lt 69 ]]; then
556-
CUSTOM_LIBS=$ALL_BOOST_LIBS_1_68
559+
BOOST_LIBS=("${ALL_BOOST_LIBS_1_68[@]}")
557560
else
558-
CUSTOM_LIBS=$ALL_BOOST_LIBS_1_69
561+
BOOST_LIBS=("${ALL_BOOST_LIBS_1_69[@]}")
559562
fi
563+
else
564+
read -ra BOOST_LIBS <<< "$CUSTOM_LIBS"
560565
fi
561-
BOOST_LIBS=$CUSTOM_LIBS
562566
fi
563567

564568
# Force 32/64-bit architecture when building universal macOS.
@@ -717,7 +721,7 @@ updateBoostUserConfigJam()
717721
echo "Updating boost into $BOOST_SRC..."
718722

719723
USING_MPI=
720-
if [[ $BOOST_LIBS == *"mpi"* ]]; then
724+
if [[ "${BOOST_LIBS[*]}" =~ "mpi" ]]; then
721725
USING_MPI="using mpi ;" # trailing space needed
722726
fi
723727

@@ -796,32 +800,29 @@ EOF
796800
bootstrapBoost()
797801
{
798802
cd_or_abort "$BOOST_SRC"
799-
if [[ -z $BOOST_LIBS ]]; then
800-
./bootstrap.sh --without-libraries="${ALL_BOOST_LIBS// /,}"
803+
if [[ ${#BOOST_LIBS[@]} -eq 0 ]]; then
804+
ALL_BOOST_LIBS_COMMA=$(IFS=, ; echo "${ALL_BOOST_LIBS[*]}")
805+
./bootstrap.sh --without-libraries="$ALL_BOOST_LIBS_COMMA"
801806
else
802-
BOOTSTRAP_LIBS=$BOOST_LIBS
807+
BOOTSTRAP_LIBS=("${BOOST_LIBS[@]}")
803808
# Strip out unsupported / unavailable libraries
804809
if [[ "$1" == "iOS" ]]; then
805-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//context/}"
806-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//coroutine/}"
807-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//coroutine2/}"
808-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//math/}"
809-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//mpi/}"
810+
UNSUPPORTED_LIBS=("context" "coroutine" "coroutine2" "math" "mpi")
811+
for LIB in "${UNSUPPORTED_LIBS[@]}"; do
812+
BOOTSTRAP_LIBS=("${BOOTSTRAP_LIBS[@]/$LIB}")
813+
done
810814
fi
811815

812816
if [[ "$1" == "tvOS" ]]; then
813-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//container/}"
814-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//context/}"
815-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//coroutine/}"
816-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//coroutine2/}"
817-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//math/}"
818-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//metaparse/}"
819-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//mpi/}"
820-
BOOTSTRAP_LIBS="${BOOTSTRAP_LIBS//test/}"
817+
UNSUPPORTED_LIBS=("container" "context" "coroutine" "coroutine2"
818+
"math" "metaparse" "mpi" "test")
819+
for LIB in "${UNSUPPORTED_LIBS[@]}"; do
820+
BOOTSTRAP_LIBS=("${BOOTSTRAP_LIBS[@]/$LIB}")
821+
done
821822
fi
822823

823-
echo "Bootstrap libs ${BOOTSTRAP_LIBS}"
824-
BOOST_LIBS_COMMA="${BOOTSTRAP_LIBS// /,}"
824+
echo "Bootstrap libs" "${BOOTSTRAP_LIBS[@]}"
825+
BOOST_LIBS_COMMA=$(IFS=, ; echo "${BOOTSTRAP_LIBS[*]}")
825826
echo "Bootstrapping for $1 (with libs $BOOST_LIBS_COMMA)"
826827
./bootstrap.sh --with-libraries="$BOOST_LIBS_COMMA"
827828
fi
@@ -1086,7 +1087,7 @@ scrunchAllLibsTogetherInOneLibPerPlatform()
10861087

10871088
echo Splitting all existing fat binaries...
10881089

1089-
for NAME in $BOOTSTRAP_LIBS; do
1090+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
10901091
if [ "$NAME" == "test" ]; then
10911092
NAME="unit_test_framework"
10921093
fi
@@ -1176,7 +1177,7 @@ scrunchAllLibsTogetherInOneLibPerPlatform()
11761177

11771178
echo "Decomposing each architecture's .a files"
11781179

1179-
for NAME in $BOOTSTRAP_LIBS; do
1180+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
11801181
if [ "$NAME" == "test" ]; then
11811182
NAME="unit_test_framework"
11821183
fi
@@ -1256,7 +1257,7 @@ scrunchAllLibsTogetherInOneLibPerPlatform()
12561257
done
12571258
fi
12581259

1259-
for NAME in $BOOTSTRAP_LIBS; do
1260+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
12601261
if [ "$NAME" == "test" ]; then
12611262
NAME="unit_test_framework"
12621263
fi
@@ -1316,7 +1317,7 @@ buildUniversal()
13161317
mkdir -p "$IOS_BUILD_DIR/universal"
13171318

13181319
cd_or_abort "$IOS_BUILD_DIR"
1319-
for NAME in $BOOTSTRAP_LIBS; do
1320+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
13201321
if [ "$NAME" == "test" ]; then
13211322
NAME="unit_test_framework"
13221323
fi
@@ -1338,7 +1339,7 @@ buildUniversal()
13381339
mkdir -p "$TVOS_BUILD_DIR/universal"
13391340

13401341
cd_or_abort "$TVOS_BUILD_DIR"
1341-
for NAME in $BOOTSTRAP_LIBS; do
1342+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
13421343
if [ "$NAME" == "test" ]; then
13431344
NAME="unit_test_framework"
13441345
fi
@@ -1360,7 +1361,7 @@ buildUniversal()
13601361
mkdir -p "$MACOS_BUILD_DIR/universal"
13611362

13621363
cd_or_abort "$MACOS_BUILD_DIR"
1363-
for NAME in $BOOTSTRAP_LIBS; do
1364+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
13641365
if [ "$NAME" == "test" ]; then
13651366
NAME="unit_test_framework"
13661367
fi
@@ -1380,7 +1381,7 @@ buildUniversal()
13801381
mkdir -p "$MACOS_SILICON_BUILD_DIR/universal"
13811382

13821383
cd_or_abort "$MACOS_SILICON_BUILD_DIR"
1383-
for NAME in $BOOTSTRAP_LIBS; do
1384+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
13841385
if [ "$NAME" == "test" ]; then
13851386
NAME="unit_test_framework"
13861387
fi
@@ -1400,7 +1401,7 @@ buildUniversal()
14001401
mkdir -p "$MAC_CATALYST_BUILD_DIR/universal"
14011402

14021403
cd_or_abort "$MAC_CATALYST_BUILD_DIR"
1403-
for NAME in $BOOTSTRAP_LIBS; do
1404+
for NAME in "${BOOTSTRAP_LIBS[@]}"; do
14041405
if [ "$NAME" == "test" ]; then
14051406
NAME="unit_test_framework"
14061407
fi
@@ -1452,7 +1453,7 @@ buildXCFramework()
14521453
ARCH_FILES+=("$IOS_BUILD_DIR/iphonesimulator/$ARCH/libboost.a")
14531454
done
14541455
$IOS_DEV_CMD lipo -create "${ARCH_FILES[@]}" -o "$IOS_BUILD_DIR/iphonesimulator/libboost.a" || abort "iOS Simulator Lipo failed"
1455-
1456+
14561457
for LIBPATH in "$IOS_OUTPUT_DIR"/build/*/libboost.a; do
14571458
LIB_ARGS+=('-library' "$LIBPATH")
14581459
SLICES_COUNT=$((SLICES_COUNT + 1))
@@ -1477,7 +1478,7 @@ buildXCFramework()
14771478
ARCH_FILES+=("$TVOS_BUILD_DIR/appletvsimulator/$ARCH/libboost.a")
14781479
done
14791480
$TVOS_DEV_CMD lipo -create "${ARCH_FILES[@]}" -o "$TVOS_BUILD_DIR/appletvsimulator/libboost.a" || abort "tvOS Simulator Lipo failed"
1480-
1481+
14811482
for LIBPATH in "$TVOS_OUTPUT_DIR"/build/*/libboost.a; do
14821483
LIB_ARGS+=('-library' "$LIBPATH")
14831484
SLICES_COUNT=$((SLICES_COUNT + 1))

0 commit comments

Comments
 (0)