forked from moritz-wundke/Boost-for-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-android.sh
executable file
·711 lines (631 loc) · 21.7 KB
/
build-android.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
#!/bin/sh
# Copyright (C) 2010 Mystic Tree Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Author: Moritz "Moss" Wundke ([email protected])
#
# <License>
#
# Build boost for android completely. It will download boost 1.45.0
# prepare the build system and finally build it for android
SCRIPTDIR="$(cd "$(dirname "$0")"; pwd)" # " # This extra quote fixes syntax highlighting in mcedit
# Add common build methods
. "$SCRIPTDIR"/build-common.sh
# -----------------------
# Command line arguments
# -----------------------
BOOST_VER1=1
BOOST_VER2=85
BOOST_VER3=0
register_option "--boost=<version>" boost_version "Boost version to be used, one of {1.85.0 1.84.0 1.83.0 1.82.0 1.80.0 1.79.0 1.78.0 1.76.0 1.74.0, 1.73.0, 1.71.0, 1.70.0, 1.69.0, 1.68.0, 1.67.0, 1.66.0, 1.65.1, 1.55.0, 1.54.0, 1.53.0, 1.49.0, 1.48.0, 1.45.0}, default is 1.85.0."
boost_version()
{
if [ "$1" = "1.85.0" ]; then
BOOST_VER1=1
BOOST_VER2=85
BOOST_VER3=0
elif [ "$1" = "1.84.0" ]; then
BOOST_VER1=1
BOOST_VER2=84
BOOST_VER3=0
elif [ "$1" = "1.83.0" ]; then
BOOST_VER1=1
BOOST_VER2=83
BOOST_VER3=0
elif [ "$1" = "1.82.0" ]; then
BOOST_VER1=1
BOOST_VER2=82
BOOST_VER3=0
elif [ "$1" = "1.80.0" ]; then
BOOST_VER1=1
BOOST_VER2=80
BOOST_VER3=0
elif [ "$1" = "1.79.0" ]; then
BOOST_VER1=1
BOOST_VER2=79
BOOST_VER3=0
elif [ "$1" = "1.78.0" ]; then
BOOST_VER1=1
BOOST_VER2=78
BOOST_VER3=0
elif [ "$1" = "1.77.0" ]; then
BOOST_VER1=1
BOOST_VER2=77
BOOST_VER3=0
elif [ "$1" = "1.76.0" ]; then
BOOST_VER1=1
BOOST_VER2=76
BOOST_VER3=0
elif [ "$1" = "1.74.0" ]; then
BOOST_VER1=1
BOOST_VER2=74
BOOST_VER3=0
elif [ "$1" = "1.73.0" ]; then
BOOST_VER1=1
BOOST_VER2=73
BOOST_VER3=0
elif [ "$1" = "1.71.0" ]; then
BOOST_VER1=1
BOOST_VER2=71
BOOST_VER3=0
elif [ "$1" = "1.70.0" ]; then
BOOST_VER1=1
BOOST_VER2=70
BOOST_VER3=0
elif [ "$1" = "1.69.0" ]; then
BOOST_VER1=1
BOOST_VER2=69
BOOST_VER3=0
elif [ "$1" = "1.68.0" ]; then
BOOST_VER1=1
BOOST_VER2=68
BOOST_VER3=0
elif [ "$1" = "1.67.0" ]; then
BOOST_VER1=1
BOOST_VER2=67
BOOST_VER3=0
elif [ "$1" = "1.66.0" ]; then
BOOST_VER1=1
BOOST_VER2=66
BOOST_VER3=0
elif [ "$1" = "1.65.1" ]; then
BOOST_VER1=1
BOOST_VER2=65
BOOST_VER3=1
elif [ "$1" = "1.55.0" ]; then
BOOST_VER1=1
BOOST_VER2=55
BOOST_VER3=0
elif [ "$1" = "1.54.0" ]; then
BOOST_VER1=1
BOOST_VER2=54
BOOST_VER3=0
elif [ "$1" = "1.53.0" ]; then
BOOST_VER1=1
BOOST_VER2=53
BOOST_VER3=0
elif [ "$1" = "1.49.0" ]; then
BOOST_VER1=1
BOOST_VER2=49
BOOST_VER3=0
elif [ "$1" = "1.48.0" ]; then
BOOST_VER1=1
BOOST_VER2=48
BOOST_VER3=0
elif [ "$1" = "1.45.0" ]; then
BOOST_VER1=1
BOOST_VER2=45
BOOST_VER3=0
else
echo "Unsupported boost version '$1'."
exit 1
fi
}
register_option "--toolchain=<toolchain>" select_toolchain "Select a toolchain. To see available execute ls -l ANDROID_NDK/toolchains."
select_toolchain () {
TOOLCHAIN=$1
}
EXTRA_PARAMS=
register_option "--extra=<params>" add_extra_params "Add extra b2 parameters for the build."
add_extra_params () {
for param in $(echo $1 | tr ',' '\n') ; do EXTRA_PARAMS="${EXTRA_PARAMS} $param"; done
}
CLEAN=no
register_option "--clean" do_clean "Delete all previously downloaded and built files, then exit."
do_clean () { CLEAN=yes; }
DOWNLOAD=no
register_option "--download" do_download "Only download required files and clean up previus build. No build will be performed."
do_download ()
{
DOWNLOAD=yes
}
#LIBRARIES=--with-libraries=date_time,filesystem,program_options,regex,signals,system,thread,iostreams,locale
LIBRARIES=
register_option "--with-libraries=<list>" do_with_libraries "Comma separated list of libraries to build."
do_with_libraries () {
for lib in $(echo $1 | tr ',' '\n') ; do LIBRARIES="--with-$lib ${LIBRARIES}"; done
}
register_option "--without-libraries=<list>" do_without_libraries "Comma separated list of libraries to exclude from the build."
do_without_libraries () { LIBRARIES="--without-libraries=$1"; }
do_without_libraries () {
for lib in $(echo $1 | tr ',' '\n') ; do LIBRARIES="--without-$lib ${LIBRARIES}"; done
}
LAYOUT=versioned
register_option "--layout=<layout>" do_layout "Library naming layout [versioned, tagged, system]."
do_layout () {
LAYOUT=$1;
}
ARCHLIST=
register_option "--arch=<list>" do_arch "Comma separated list of architectures to build: arm64-v8a,armeabi,armeabi-v7a,mips,mips64,x86,x86_64"
do_arch () {
for ARCH in $(echo $1 | tr ',' '\n') ; do ARCHLIST="$ARCH ${ARCHLIST}"; done
}
ANDROID_TARGET_32=21
ANDROID_TARGET_64=21
register_option "--target-version=<version>" select_target_version \
"Select Android's target version" "$ANDROID_TARGET_32"
select_target_version () {
if [ "$1" -lt 16 ]; then
ANDROID_TARGET_32="16"
ANDROID_TARGET_64="21"
elif [ "$1" = 20 ]; then
ANDROID_TARGET_32="19"
ANDROID_TARGET_64="21"
elif [ "$1" -lt 21 ]; then
ANDROID_TARGET_32="$1"
ANDROID_TARGET_64="21"
elif [ "$1" = 25 ]; then
ANDROID_TARGET_32="24"
ANDROID_TARGET_64="24"
else
ANDROID_TARGET_32="$1"
ANDROID_TARGET_64="$1"
fi
}
WITH_ICONV=
register_option "--with-iconv" do_with_iconv "Build iconv and icu libaries, for boost-locale"
do_with_iconv () {
WITH_ICONV=1
}
WITH_PYTHON=
register_option "--with-python=</path/to/python>" do_with_python "Build boost-python"
do_with_python () {
WITH_PYTHON=$1
for pylib in ${WITH_PYTHON}/lib/python*; do
pyvers_=$(basename $pylib)
PYTHON_VERSION=${pyvers_#python}
for pyinclude in ${WITH_PYTHON}/include/python${PYTHON_VERSION}*; do
PYTHON_INCLUDE_DIR=${pyinclude}
done
done
}
BOOST_DIR="boost_${BOOST_VER1}_${BOOST_VER2}_${BOOST_VER3}"
register_option "--src-dir=<boost_src_dir>" add_boost_dir "Override the default Boost source directory."
add_boost_dir () {
if [ -d $1 ]; then
BOOST_DIR=$1;
fi
}
BUILD_DIR="./build/"
register_option "--build-dir=<build_dir>" add_build_dir "Set the temporary build dir."
add_build_dir () {
BUILD_DIR=$1;
}
PREFIX="$BUILD_DIR/out/"
register_option "--prefix=<path>" do_prefix "Prefix to be used when installing libraries and includes."
do_prefix () {
PREFIX=$1;
}
PROGRAM_PARAMETERS="<ndk-root>"
PROGRAM_DESCRIPTION=\
" Boost For Android\n"\
"Copyright (C) 2010 Mystic Tree Games\n"\
extract_parameters $@
echo "Building boost version: $BOOST_VER1.$BOOST_VER2.$BOOST_VER3"
# -----------------------
# Build constants
# -----------------------
BOOST_DOWNLOAD_LINK="https://boostorg.jfrog.io/artifactory/main/release/$BOOST_VER1.$BOOST_VER2.$BOOST_VER3/source/boost_${BOOST_VER1}_${BOOST_VER2}_${BOOST_VER3}.tar.bz2"
BOOST_TAR="boost_${BOOST_VER1}_${BOOST_VER2}_${BOOST_VER3}.tar.bz2"
# -----------------------
if [ $CLEAN = yes ] ; then
echo "Cleaning: $BUILD_DIR"
rm -f -r $BUILD_DIR
echo "Cleaning: $BOOST_DIR"
rm -f -r $BOOST_DIR
echo "Cleaning: $BOOST_TAR"
rm -f $PROGDIR/$BOOST_TAR
echo "Cleaning: logs"
rm -f -r logs
rm -f build.log
[ "$DOWNLOAD" = "yes" ] || exit 0
fi
AndroidNDKRoot=$PARAMETERS
if [ -z "$AndroidNDKRoot" ] ; then
if [ -n "${ANDROID_BUILD_TOP}" ]; then # building from Android sources
AndroidNDKRoot="${ANDROID_BUILD_TOP}/prebuilts/ndk/current"
export AndroidSourcesDetected=1
elif [ -z "`which ndk-build`" ]; then
dump "ERROR: You need to provide a <ndk-root>!"
exit 1
else
AndroidNDKRoot=`which ndk-build`
AndroidNDKRoot=`dirname $AndroidNDKRoot`
fi
echo "Using AndroidNDKRoot = $AndroidNDKRoot"
else
# User passed the NDK root as a parameter. Make sure the directory
# exists and make it an absolute path. ".cmd" is for Windows support.
if [ ! -f "$AndroidNDKRoot/ndk-build" ] && [ ! -f "$AndroidNDKRoot/ndk-build.cmd" ]; then
dump "ERROR: $AndroidNDKRoot is not a valid NDK root"
exit 1
fi
AndroidNDKRoot=$(cd $AndroidNDKRoot; pwd -P)
fi
export AndroidNDKRoot
# Check platform patch
case "$HOST_OS" in
linux)
PlatformOS=linux
;;
darwin|freebsd)
PlatformOS=darwin
;;
windows|cygwin)
PlatformOS=windows
;;
*) # let's play safe here
PlatformOS=linux
esac
NDK_RELEASE_FILE=$AndroidNDKRoot"/RELEASE.TXT"
if [ -f "${NDK_RELEASE_FILE}" ]; then
NDK_RN=`cat $NDK_RELEASE_FILE | sed 's/^r\(.*\)$/\1/g'`
elif [ -n "${AndroidSourcesDetected}" ]; then
if [ -f "${ANDROID_BUILD_TOP}/ndk/docs/CHANGES.html" ]; then
NDK_RELEASE_FILE="${ANDROID_BUILD_TOP}/ndk/docs/CHANGES.html"
NDK_RN=`grep "android-ndk-" "${NDK_RELEASE_FILE}" | head -1 | sed 's/^.*r\(.*\)$/\1/'`
elif [ -f "${ANDROID_BUILD_TOP}/ndk/docs/text/CHANGES.text" ]; then
NDK_RELEASE_FILE="${ANDROID_BUILD_TOP}/ndk/docs/text/CHANGES.text"
NDK_RN=`grep "android-ndk-" "${NDK_RELEASE_FILE}" | head -1 | sed 's/^.*r\(.*\)$/\1/'`
else
dump "ERROR: can not find ndk version"
exit 1
fi
else
NDK_RELEASE_FILE=$AndroidNDKRoot"/source.properties"
if [ -f "${NDK_RELEASE_FILE}" ]; then
NDK_RN=`cat $NDK_RELEASE_FILE | grep 'Pkg.Revision' | sed -E 's/^.*[=] *([0-9]+[.][0-9]+)[.].*/\1/g'`
else
dump "ERROR: can not find ndk version"
exit 1
fi
fi
echo "Detected Android NDK version $NDK_RN"
CONFIG_VARIANT=boost
case "$NDK_RN" in
4*)
TOOLCHAIN=${TOOLCHAIN:-arm-eabi-4.4.0}
CXXPATH=$AndroidNDKRoot/build/prebuilt/$PlatformOS-x86/${TOOLCHAIN}/bin/arm-eabi-g++
TOOLSET=gcc-androidR4
;;
5*)
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.4.3}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/$PlatformOS-x86/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR5
;;
7-crystax-5.beta3)
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6.3}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/$PlatformOS-x86/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR7crystax5beta3
;;
8)
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.4.3}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/$PlatformOS-x86/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8
;;
8b|8c|8d)
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/$PlatformOS-x86/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8b
;;
8e|9|9b|9c|9d)
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/$PlatformOS-x86/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8e
;;
"8e (64-bit)")
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8e
;;
"9 (64-bit)"|"9b (64-bit)"|"9c (64-bit)"|"9d (64-bit)")
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8e
;;
"10 (64-bit)"|"10b (64-bit)"|"10c (64-bit)"|"10d (64-bit)")
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8e
;;
"10 (64-bit)"|"10b (64-bit)"|"10c (64-bit)"|"10d (64-bit)")
TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++
TOOLSET=gcc-androidR8e
;;
"16.0"|"16.1"|"17.1"|"17.2"|"18.0"|"18.1")
TOOLCHAIN=${TOOLCHAIN:-llvm}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++
TOOLSET=clang
;;
"19.0"|"19.1"|"19.2"|"20.0"|"20.1"|"21.0"|"21.1"|"21.2"|"21.3"|"21.4")
TOOLCHAIN=${TOOLCHAIN:-llvm}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++
TOOLSET=clang
CONFIG_VARIANT=ndk19
;;
"22.1"|"23.0"|"23.1"|"25.0"|"25.1"|"25.2"|"26.0"|"26.1"|"26.2"|"26.3"|"27.0"|"27.1")
TOOLCHAIN=${TOOLCHAIN:-llvm}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++
TOOLSET=clang
CONFIG_VARIANT=ndk23
;;
*)
echo "Undefined or not supported Android NDK version: $NDK_RN"
exit 1
esac
if [ -n "${AndroidSourcesDetected}" -a "${TOOLSET}" '!=' "clang" ]; then # Overwrite CXXPATH if we are building from Android sources
CXXPATH="${ANDROID_TOOLCHAIN}/arm-linux-androideabi-g++"
fi
if [ -z "${ARCHLIST}" ]; then
ARCHLIST=armeabi-v7a
if [ "$TOOLSET" = "clang" ]; then
case "$NDK_RN" in
# NDK 17+: Support for ARMv5 (armeabi), MIPS, and MIPS64 has been removed.
"17.1"|"17.2"|"18.0"|"18.1"|"19.0"|"19.1"|"19.2"|"20.0"|"20.1"|"21.0"|"21.1"|"21.2"|"21.3"|"21.4"|"22.1"|"23.0"|"23.1"|"25.0"|"25.1"|"25.2"|"26.0"|"26.1"|"26.2"|"26.3"|"27.0")
ARCHLIST="arm64-v8a armeabi-v7a x86 x86_64"
;;
*)
ARCHLIST="arm64-v8a armeabi armeabi-v7a mips mips64 x86 x86_64"
esac
fi
fi
if [ "${ARCHLIST}" '!=' "armeabi" ] && [ "${TOOLSET}" '!=' "clang" ]; then
echo "Old NDK versions only support ARM architecture"
exit 1
fi
echo Building with TOOLSET=$TOOLSET CONFIG_VARIANT=${CONFIG_VARIANT} CXXPATH=$CXXPATH CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS | tee $PROGDIR/build.log
# Check if the ndk is valid or not
if [ ! -f $CXXPATH ]
then
echo "Cannot find C++ compiler at: $CXXPATH"
exit 1
fi
# -----------------------
# Download required files
# -----------------------
# Download and unzip boost in a temporary folder and
if [ "${DOWNLOAD}" = "yes" ]
then
if [ ! -f $BOOST_TAR ]
then
echo "Downloading boost ${BOOST_VER1}.${BOOST_VER2}.${BOOST_VER3} please wait..."
prepare_download
download_file $BOOST_DOWNLOAD_LINK $PROGDIR/$BOOST_TAR
if [ ! -f $PROGDIR/$BOOST_TAR ]
then
echo "Failed to download boost! Please download boost ${BOOST_VER1}.${BOOST_VER2}.${BOOST_VER3} manually\nand save it in this directory as $BOOST_TAR"
exit 1
fi
fi
# clean any previous directory
if [ -d $BOOST_DIR ]
then
rm -rf $BOOST_DIR
fi
echo "Unpacking boost"
if [ "$OPTION_PROGRESS" = "yes" ] ; then
pv $PROGDIR/$BOOST_TAR | tar xjf - -C $BOOST_DIR
else
tar xjf $PROGDIR/$BOOST_TAR -C $BOOST_DIR
fi
echo "All required files has been downloaded and unpacked!"
fi
# Apply patches to boost
BOOST_VER=${BOOST_VER1}_${BOOST_VER2}_${BOOST_VER3}
# ---------
# Bootstrap
# ---------
if [ ! -f $BOOST_DIR/b2 ]
then
# Make the initial bootstrap
echo "Performing boost bootstrap"
cd $BOOST_DIR
case "$HOST_OS" in
windows)
cmd //c "bootstrap.bat" 2>&1 | teelog
;;
*) # Linux and others
./bootstrap.sh 2>&1 | teelog
esac
if [ $? != 0 ] ; then
dump "ERROR: Could not perform boostrap! See $TMPLOG for more info."
exit 1
fi
cd $PROGDIR
# -------------------------------------------------------------
# Patching will be done only if we had a successful bootstrap!
# -------------------------------------------------------------
PATCH_BOOST_DIR="$SCRIPTDIR/patches/boost-${BOOST_VER}"
for dir in $PATCH_BOOST_DIR; do
if [ ! -d "$dir" ]; then
echo "Could not find directory '$dir' while looking for patches" 2>&1 | teelog
exit 1
fi
PATCHES=`(cd $dir && ls *.patch | sort) 2> /dev/null`
if [ -z "$PATCHES" ]; then
echo "No patches found in directory '$dir'"
exit 1
fi
for PATCH in $PATCHES; do
PATCH=`echo $PATCH | sed -e s%^\./%%g`
SRC_DIR=$BOOST_DIR
PATCHDIR=`dirname $PATCH`
PATCHNAME=`basename $PATCH`
log "Applying $PATCHNAME into $SRC_DIR/$PATCHDIR"
cd $SRC_DIR
echo "Running: `which patch` -p1 < $dir/$PATCH in `pwd`"
patch -p1 < $dir/$PATCH
if [ $? != 0 ] ; then
dump "ERROR: Patch failure !! Please check your patches directory!"
dump " Try to perform a clean build using --clean ."
dump " Problem patch: $dir/$PATCH into $SRC_DIR"
exit 1
fi
cd $PROGDIR
done
done
fi
if [ ! -f $SCRIPTDIR/user-config.jam ]
then
echo "# ------------------------------------"
echo "# Creating $SCRIPTDIR/user-config.jam "
echo "# ------------------------------------"
if [ "$TOOLSET" = "clang" ]; then
cp "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}.jam "$SCRIPTDIR"/user-config.jam || exit 1
for FILE in "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-*.jam; do
ARCH="`echo $FILE | sed s%$SCRIPTDIR/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-%% | sed s/[.]jam//`"
if [ "$ARCH" = "common" ]; then
continue
fi
JAMARCH="`echo ${ARCH} | tr -d '_-'`" # Remove all dashes, b2 does not like them
sed "s/%ARCH%/${JAMARCH}/g" "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-common.jam >> "$SCRIPTDIR"/user-config.jam || exit 1
cat "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-$ARCH.jam >> "$SCRIPTDIR"/user-config.jam || exit 1
echo ';' >> "$SCRIPTDIR"/user-config.jam || exit 1
done
else
cp "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}.jam "$SCRIPTDIR"/user-config.jam || exit 1
fi
if [ -n "$WITH_PYTHON" ]; then
echo "Sed: $WITH_PYTHON"
sed -e "s:%PYTHON_VERSION%:${PYTHON_VERSION}:g;s:%PYTHON_INSTALL_DIR%:${WITH_PYTHON}:g;s:%PYTHON_INCLUDE_DIR%:${PYTHON_INCLUDE_DIR}:g" "$SCRIPTDIR"/configs/user-config-python.jam >> $BOOST_DIR/tools/build/src/user-config-python.jam || exit 1
cat $BOOST_DIR/tools/build/src/user-config-python.jam >> $SCRIPTDIR/user-config.jam
fi
fi
echo "# ---------------"
echo "# Build using NDK"
echo "# ---------------"
if [ -z "$NCPU" ]; then
NCPU=4
if uname -s | grep -i "linux" > /dev/null ; then
NCPU=`cat /proc/cpuinfo | grep -c -i processor`
fi
fi
for ARCH in $ARCHLIST; do
echo "Building boost for android for $ARCH"
(
PREFIX_ARCH_DIR="$PREFIX/$ARCH"
if [ -n "$WITH_ICONV" ] || echo $LIBRARIES | grep locale; then
if [ -e libiconv-libicu-android ]; then
echo "ICONV and ICU already downloaded"
else
echo "Downloading libiconv-libicu-android repo"
git clone --depth=1 https://github.com/pelya/libiconv-libicu-android.git || exit 1
fi
if [ -e libiconv-libicu-android/$ARCH/libicuuc.a ]; then
echo "ICONV and ICU already compiled"
else
echo "boost_locale selected - compiling ICONV and ICU"
cd libiconv-libicu-android
ARCHS=$ARCH PATH=$AndroidNDKRoot:$PATH ./build.sh || exit 1
cd ..
fi
fi
cd $BOOST_DIR
echo "Adding pathname: `dirname $CXXPATH`" | teelog
# `AndroidBinariesPath` could be used by user-config-*.jam
export AndroidBinariesPath=`dirname $CXXPATH`
export PATH=$AndroidBinariesPath:$PATH
export AndroidNDKRoot=$AndroidNDKRoot
export AndroidTargetVersion32=$ANDROID_TARGET_32
export AndroidTargetVersion64=$ANDROID_TARGET_64
export NO_BZIP2=1
export PlatformOS=$PlatformOS
cflags=""
for flag in $CFLAGS; do cflags="$cflags cflags=$flag"; done
cxxflags=""
for flag in $CXXFLAGS; do cxxflags="$cxxflags cxxflags=$flag"; done
LIBRARIES_BROKEN=""
if [ "$TOOLSET" = "clang" ]; then
JAMARCH="`echo ${ARCH} | tr -d '_-'`" # Remove all dashes, b2 does not like them
TOOLSET_ARCH=${TOOLSET}-${JAMARCH}
TARGET_OS=android
if [ "$ARCH" = "armeabi" ]; then
if [ -z "$LIBRARIES" ]; then
echo "Disabling boost_math library on armeabi architecture, because of broken toolchain" | tee -a $PROGDIR/build.log
LIBRARIES_BROKEN="--without-math"
elif echo $LIBRARIES | grep math; then
dump "ERROR: Cannot build boost_math library for armeabi architecture because of broken toolchain"
dump " However, it is explicitly included"
exit 1
fi
fi
else
TOOLSET_ARCH=${TOOLSET}
TARGET_OS=linux
fi
if [ -n "$WITH_PYTHON" ]; then
WITHOUT_LIBRARIES=
PYTHON_BUILD=python=${PYTHON_VERSION}
else
WITHOUT_LIBRARIES=--without-python
PYTHON_BUILD=
fi
if [ -n "$LIBRARIES" ]; then
unset WITHOUT_LIBRARIES
fi
if [ $VERBOSE = 'no' ]; then
echo "Silently building Boost, this can take minutes..."
fi
{
$TIME_CMD ./b2 -q \
-d+2 \
--user-config=$SCRIPTDIR/user-config.jam \
--ignore-site-config \
-j$NCPU \
target-os=${TARGET_OS} \
toolset=${TOOLSET_ARCH} \
$cflags \
$cxxflags \
link=static \
runtime-link=static \
threading=multi \
--layout=${LAYOUT} \
$WITHOUT_LIBRARIES \
$PYTHON_BUILD \
-sICONV_PATH=`pwd`/../libiconv-libicu-android/$ARCH \
-sICU_PATH=`pwd`/../libiconv-libicu-android/$ARCH \
--build-dir="$BUILD_DIR" \
--prefix="$PREFIX" \
$EXTRA_PARAMS \
$LIBRARIES \
$LIBRARIES_BROKEN \
install 2>&1 \
|| { dump "ERROR: Failed to build boost for android for $ARCH!" ; rm -rf $PREFIX ; exit 1 ; }
} | teelog
)
#
# PIPESTATUS variable is defined only in Bash, and we are using /bin/sh, which is not Bash on newer Debian/Ubuntu
dump "Done!"
done # for ARCH in $ARCHLIST