Skip to content

Commit

Permalink
Experimental support for NDK r19, using shared libc++, as recommended…
Browse files Browse the repository at this point in the history
… by NDK documentation
  • Loading branch information
pelya committed Jan 25, 2019
1 parent 286a548 commit 87e3f5d
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ To compile Boost for Android you may use one of the following NDKs:
| r17b from the [official android repository](http://developer.android.com). | | | | | | | x | x | |
| r18 from the [official android repository](http://developer.android.com). | | | | | | | | x | |
| r18b from the [official android repository](http://developer.android.com). | | | | | | | | x | x |
| r19 from the [official android repository](http://developer.android.com). | | | | | | | | | x |

# Quick Start

Expand Down
32 changes: 20 additions & 12 deletions build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ fi

echo "Detected Android NDK version $NDK_RN"

CONFIG_VARIANT=boost

case "$NDK_RN" in
4*)
TOOLCHAIN=${TOOLCHAIN:-arm-eabi-4.4.0}
Expand Down Expand Up @@ -303,6 +305,12 @@ case "$NDK_RN" in
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++
TOOLSET=clang
;;
"19.0")
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
Expand All @@ -318,7 +326,7 @@ if [ -z "${ARCHLIST}" ]; 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")
"17.1"|"17.2"|"18.0"|"18.1"|"19.0")
ARCHLIST="arm64-v8a armeabi-v7a x86 x86_64"
;;
*)
Expand All @@ -332,7 +340,7 @@ if [ "${ARCHLIST}" '!=' "armeabi" ] && [ "${TOOLSET}" '!=' "clang" ]; then
exit 1
fi

echo Building with TOOLSET=$TOOLSET CXXPATH=$CXXPATH CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS | tee $PROGDIR/build.log
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 ]
Expand Down Expand Up @@ -407,19 +415,19 @@ then
PATCH_BOOST_DIR=$PROGDIR/patches/boost-${BOOST_VER}

if [ "$TOOLSET" = "clang" ]; then
cp configs/user-config-boost-${BOOST_VER}.jam $BOOST_DIR/tools/build/src/user-config.jam || exit 1
for FILE in configs/user-config-boost-${BOOST_VER}-*.jam; do
ARCH="`echo $FILE | sed s%configs/user-config-boost-${BOOST_VER}-%% | sed s/[.]jam//`"
cp configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}.jam $BOOST_DIR/tools/build/src/user-config.jam || exit 1
for FILE in configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-*.jam; do
ARCH="`echo $FILE | sed s%configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-%% | sed s/[.]jam//`"
if [ "$ARCH" = "common" ]; then
continue
fi
JAMARCH="`echo ${ARCH} | tr -d '_-'`" # Remove all dashes, bjam does not like them
sed "s/%ARCH%/${JAMARCH}/g" configs/user-config-boost-${BOOST_VER}-common.jam >> $BOOST_DIR/tools/build/src/user-config.jam || exit 1
cat configs/user-config-boost-${BOOST_VER}-$ARCH.jam >> $BOOST_DIR/tools/build/src/user-config.jam || exit 1
sed "s/%ARCH%/${JAMARCH}/g" configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}-common.jam >> $BOOST_DIR/tools/build/src/user-config.jam || exit 1
cat 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 configs/user-config-boost-${BOOST_VER}.jam $BOOST_DIR/tools/build/v2/user-config.jam || exit 1
cp configs/user-config-${CONFIG_VARIANT}-${BOOST_VER}.jam $BOOST_DIR/tools/build/v2/user-config.jam || exit 1
fi

for dir in $PATCH_BOOST_DIR; do
Expand Down Expand Up @@ -473,7 +481,7 @@ echo "Building boost for android for $ARCH"
echo "ICONV and ICU already compiled"
else
echo "boost_locale selected - compiling ICONV and ICU"
git clone https://github.com/pelya/libiconv-libicu-android.git
git clone --depth=1 https://github.com/pelya/libiconv-libicu-android.git
cd libiconv-libicu-android
./build.sh || exit 1
cd ..
Expand All @@ -483,12 +491,12 @@ echo "Building boost for android for $ARCH"
cd $BOOST_DIR

echo "Adding pathname: `dirname $CXXPATH`"
# `AndroidBinariesPath` could be used by user-config-boost-*.jam
# `AndroidBinariesPath` could be used by user-config-*.jam
export AndroidBinariesPath=`dirname $CXXPATH`
export PATH=$AndroidBinariesPath:$PATH
export AndroidNDKRoot
export AndroidNDKRoot=$AndroidNDKRoot
export NO_BZIP2=1
export PlatformOS
export PlatformOS=$PlatformOS

cflags=""
for flag in $CFLAGS; do cflags="$cflags cflags=$flag"; done
Expand Down
1 change: 1 addition & 0 deletions configs/user-config-ndk19-1_69_0-arm64-v8a.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions configs/user-config-ndk19-1_69_0-armeabi-v7a.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<compileflags>-mthumb
21 changes: 21 additions & 0 deletions configs/user-config-ndk19-1_69_0-common.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# --------------------------------------------------------------------

using clang : %ARCH%
:
$(AndroidCompiler_%ARCH%)
:
<archiver>$(AndroidBinariesPath)/llvm-ar
<compileflags>-fPIC
<compileflags>-ffunction-sections
<compileflags>-fdata-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-no-canonical-prefixes
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-frtti
<compileflags>-fexceptions
<compileflags>-DNDEBUG
<compileflags>-g
<compileflags>-Oz
1 change: 1 addition & 0 deletions configs/user-config-ndk19-1_69_0-x86.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions configs/user-config-ndk19-1_69_0-x86_64.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

47 changes: 47 additions & 0 deletions configs/user-config-ndk19-1_69_0.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2003, 2005 Douglas Gregor
# Copyright 2004 John Maddock
# Copyright 2002, 2003, 2004, 2007 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

# This file is used to configure your Boost.Build installation. You can modify
# this file in place, or you can place it in a permanent location so that it
# does not get overwritten should you get a new version of Boost.Build. See:
#
# http://www.boost.org/boost-build2/doc/html/bbv2/overview/configuration.html
#
# for documentation about possible permanent locations.

# This file specifies which toolsets (C++ compilers), libraries, and other
# tools are available. Often, you should be able to just uncomment existing
# example lines and adjust them to taste. The complete list of supported tools,
# and configuration instructions can be found at:
#
# http://boost.org/boost-build2/doc/html/bbv2/reference/tools.html
#

# This file uses Jam language syntax to describe available tools. Mostly,
# there are 'using' lines, that contain the name of the used tools, and
# parameters to pass to those tools -- where paremeters are separated by
# semicolons. Important syntax notes:
#
# - Both ':' and ';' must be separated from other tokens by whitespace
# - The '\' symbol is a quote character, so when specifying Windows paths you
# should use '/' or '\\' instead.
#
# More details about the syntax can be found at:
#
# http://boost.org/boost-build2/doc/html/bbv2/advanced.html#bbv2.advanced.jam_language
#
# ------------------
# Android configurations.
# ------------------

import os ;
local AndroidNDKRoot = [ os.environ AndroidNDKRoot ] ;
local AndroidBinariesPath = [ os.environ AndroidBinariesPath ] ;

local AndroidCompiler_arm64v8a = $(AndroidBinariesPath)/aarch64-linux-android21-clang++ ;
local AndroidCompiler_armeabiv7a = $(AndroidBinariesPath)/armv7a-linux-androideabi16-clang++ ;
local AndroidCompiler_x86 = $(AndroidBinariesPath)/i686-linux-android16-clang++ ;
local AndroidCompiler_x8664 = $(AndroidBinariesPath)/x86_64-linux-android21-clang++ ;
18 changes: 18 additions & 0 deletions patches/boost-1_69_0/boost-1_69_0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,21 @@ diff -u -r boost_1_69_0.orig/libs/filesystem/src/operations.cpp boost_1_69_0/lib
typedef int err_t;

// POSIX uses a 0 return to indicate success
diff -u -r boost_1_69_0.orig/tools/build/src/tools/common.jam boost_1_69_0/tools/build/src/tools/common.jam
--- boost_1_69_0.orig/tools/build/src/tools/common.jam 2019-01-25 23:18:34.544755629 +0200
+++ boost_1_69_0/tools/build/src/tools/common.jam 2019-01-25 23:20:42.309047754 +0200
@@ -976,10 +976,10 @@
}

# Ditto, from Clang 4
- if $(tag) in clang clangw && [ numbers.less 3 $(version[1]) ]
- {
- version = $(version[1]) ;
- }
+ #if $(tag) in clang clangw && [ numbers.less 3 $(version[1]) ]
+ #{
+ # version = $(version[1]) ;
+ #}

# On intel, version is not added, because it does not matter and it is the
# version of vc used as backend that matters. Ideally, we should encode the

0 comments on commit 87e3f5d

Please sign in to comment.