forked from moritz-wundke/Boost-for-Android
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-android.sh
executable file
·631 lines (556 loc) · 19.6 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
#!/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 completly. 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=73
BOOST_VER3=0
register_option "--boost=<version>" boost_version "Boost version to be used, one of {1.73.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.73.0."
boost_version()
{
if [ "$1" = "1.73.0" ]; then
BOOST_VER1=1
BOOST_VER2=73
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
}
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
# Clean previus stuff too!
CLEAN=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
}
register_option "--prefix=<path>" do_prefix "Prefix to be used when installing libraries and includes."
do_prefix () {
if [ -d $1 ]; then
PREFIX=$1;
fi
}
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}
done
}
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="http://dl.bintray.com/boostorg/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"
BOOST_DIR="boost_${BOOST_VER1}_${BOOST_VER2}_${BOOST_VER3}"
BUILD_DIR="./build/"
# -----------------------
if [ $CLEAN = yes ] ; then
echo "Cleaning: $BUILD_DIR"
rm -f -r $PROGDIR/$BUILD_DIR
echo "Cleaning: $BOOST_DIR"
rm -f -r $PROGDIR/$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
# It is almost never desirable to have the boost-X_Y_Z directory from
# previous builds as this script doesn't check in which state it's
# been left (bootstrapped, patched, built, ...). Unless maybe during
# a debug, in which case it's easy for a developer to comment out
# this code.
if [ -d "$PROGDIR/$BOOST_DIR" ]; then
echo "Cleaning: $BOOST_DIR"
rm -f -r $PROGDIR/$BOOST_DIR
fi
if [ -d "$PROGDIR/$BUILD_DIR" ]; then
echo "Cleaning: $BUILD_DIR"
rm -f -r $PROGDIR/$BUILD_DIR
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")
TOOLCHAIN=${TOOLCHAIN:-llvm}
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++
TOOLSET=clang
CONFIG_VARIANT=ndk19
;;
*)
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")
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
# -----------------------
# Downalod and unzip boost in a temporal folder and
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
fi
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
if [ ! -d $PROGDIR/$BOOST_DIR ]
then
echo "Unpacking boost"
if [ "$OPTION_PROGRESS" = "yes" ] ; then
pv $PROGDIR/$BOOST_TAR | tar xjf - -C $PROGDIR
else
tar xjf $PROGDIR/$BOOST_TAR
fi
fi
if [ $DOWNLOAD = yes ] ; then
echo "All required files has been downloaded and unpacked!"
exit 0
fi
# ---------
# 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 | tee -a $PROGDIR/build.log
;;
*) # Linux and others
./bootstrap.sh 2>&1 | tee -a $PROGDIR/build.log
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 successfull bootstrap!
# -------------------------------------------------------------
# Apply patches to boost
BOOST_VER=${BOOST_VER1}_${BOOST_VER2}_${BOOST_VER3}
PATCH_BOOST_DIR="$SCRIPTDIR/patches/boost-${BOOST_VER}"
if [ "$TOOLSET" = "clang" ]; then
cp "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}.jam $BOOST_DIR/tools/build/src/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 >> $BOOST_DIR/tools/build/src/user-config.jam || exit 1
cat "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-$ARCH.jam >> $BOOST_DIR/tools/build/src/user-config.jam || exit 1
echo ';' >> $BOOST_DIR/tools/build/src/user-config.jam || exit 1
done
else
cp "$SCRIPTDIR"/configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}.jam $BOOST_DIR/tools/build/v2/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" "$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 >> $BOOST_DIR/tools/build/src/user-config.jam
fi
for dir in $PATCH_BOOST_DIR; do
if [ ! -d "$dir" ]; then
echo "Could not find directory '$dir' while looking for patches"
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=$PROGDIR/$BOOST_DIR
PATCHDIR=`dirname $PATCH`
PATCHNAME=`basename $PATCH`
log "Applying $PATCHNAME into $SRC_DIR/$PATCHDIR"
cd $SRC_DIR && patch -p1 < $dir/$PATCH && cd $PROGDIR
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/$PATCHNAME"
exit 1
fi
done
done
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"
(
if [ -n "$WITH_ICONV" ] || echo $LIBRARIES | grep locale; then
if [ -e libiconv-libicu-android ]; then
echo "ICONV and ICU already compiled"
else
echo "boost_locale selected - compiling ICONV and ICU"
git clone --depth=1 https://github.com/pelya/libiconv-libicu-android.git
cd libiconv-libicu-android
./build.sh || exit 1
cd ..
fi
fi
cd $BOOST_DIR
echo "Adding pathname: `dirname $CXXPATH`"
# `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
{
./b2 -q \
-d+2 \
--ignore-site-config \
-j$NCPU \
target-os=${TARGET_OS} \
toolset=${TOOLSET_ARCH} \
$cflags \
$cxxflags \
link=static \
threading=multi \
--layout=versioned \
$WITHOUT_LIBRARIES \
$PYTHON_BUILD \
-sICONV_PATH=`pwd`/../libiconv-libicu-android/$ARCH \
-sICU_PATH=`pwd`/../libiconv-libicu-android/$ARCH \
--build-dir="./../$BUILD_DIR/build/$ARCH" \
--prefix="./../$BUILD_DIR/out/$ARCH" \
$LIBRARIES \
$LIBRARIES_BROKEN \
install 2>&1 \
|| { dump "ERROR: Failed to build boost for android for $ARCH!" ; rm -rf ./../$BUILD_DIR/out/$ARCH ; exit 1 ; }
} | tee -a $PROGDIR/build.log
# PIPESTATUS variable is defined only in Bash, and we are using /bin/sh, which is not Bash on newer Debian/Ubuntu
)
dump "Done!"
if [ $PREFIX ]; then
echo "Prefix set, copying files to $PREFIX"
mkdir -p $PREFIX/$ARCH
cp -r $PROGDIR/$BUILD_DIR/out/$ARCH/lib $PREFIX/$ARCH/
cp -r $PROGDIR/$BUILD_DIR/out/$ARCH/include $PREFIX/$ARCH/
fi
done # for ARCH in $ARCHLIST