Skip to content
Permalink
Browse files

Android arm 64 bit support (#134)

  • Loading branch information...
lewisou authored and arturoc committed Jun 9, 2019
1 parent 4e2734d commit 16638ab57d05ea046d703891fc3e670502dd2784
@@ -44,6 +44,18 @@ matrix:
# directories:
# - ~/android-ndk-r15c
# - apothecary/build/Toolchains/armv7
- os: linux
cache: ccache
sudo: required
dist: trusty
env:
- TARGET="android"
- ARCH="arm64"

# cache:
# directories:
# - ~/android-ndk-r15c
# - apothecary/build/Toolchains/arm64

- os: linux
cache: ccache
@@ -13,6 +13,10 @@ if [ "$ABI" = "armeabi-v7a" ] || [ "$ABI" = "armeabi" ]; then
export SYSROOT="${NDK_ROOT}/platforms/$ANDROID_PLATFORM/arch-arm"
export ANDROID_PREFIX=arm-linux-androideabi
export GCC_TOOLCHAIN=$ANDROID_PREFIX-${TOOLCHAIN_VERSION}
elif [ "$ABI" = "arm64-v8a" ]; then
export SYSROOT="${NDK_ROOT}/platforms/$ANDROID_PLATFORM/arch-arm64"
export ANDROID_PREFIX=aarch64-linux-android
export GCC_TOOLCHAIN=$ANDROID_PREFIX-${TOOLCHAIN_VERSION}
elif [ "$ABI" = "x86" ]; then
export SYSROOT="${NDK_ROOT}/platforms/$ANDROID_PLATFORM/arch-x86"
export ANDROID_PREFIX=i686-linux-android
@@ -25,20 +29,30 @@ export GCC_TOOLCHAIN_PATH=${NDK_ROOT}/toolchains/${GCC_TOOLCHAIN}/prebuilt/${HOS
export PATH=${PATH}:${TOOLCHAIN_PATH}
export CC=${TOOLCHAIN_PATH}/clang
export CXX=${TOOLCHAIN_PATH}/clang++
export AR=$($NDK_ROOT/ndk-which ar)
export RANLIB=$($NDK_ROOT/ndk-which ranlib)
export CFLAGS="-nostdlib --sysroot=${SYSROOT} -fno-short-enums -isystem $SYSROOT/usr/include/"
export AR=${GCC_TOOLCHAIN_PATH}/bin/${ANDROID_PREFIX}-ar
export RANLIB=${GCC_TOOLCHAIN_PATH}/bin/${ANDROID_PREFIX}-ranlib
export CFLAGS="--sysroot=${SYSROOT} -fno-short-enums -isystem $SYSROOT/usr/include/"

if [ "$ABI" != "arm64-v8a" ]; then
export CFLAGS="$CFLAGS -nostdlib"
fi

export CFLAGS="$CFLAGS -I${NDK_ROOT}/sources/cxx-stl/llvm-libc++/include -I${NDK_ROOT}/sources/android/cpufeatures -I${NDK_ROOT}/sources/android/support/include"
export LDFLAGS="-gcc-toolchain ${GCC_TOOLCHAIN_PATH} --sysroot=${SYSROOT} -L${NDK_ROOT}/sources/cxx-stl/llvm-libc++/libs/${ABI} -lz -llog -lstdc++ -lgcc -lc -lm -ldl" #-lc++ -lc++abi -lunwind
export LIBS="-lz -llog -lstdc++ -lgcc -lc -lm -ldl"
export LIBS="-lz -llog -lc -lm -ldl"
# -lstdc++ -lgcc
# -ldl -lm -lc "
#export ANDROID_SYSROOT=${SYSROOT}

if [ "$ABI" = "armeabi-v7a" ]; then
export CFLAGS="$CFLAGS -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
export LDFLAGS="$LDFLAGS -target armv7-none-linux-androideabi -march=armv7-a -Wl,--fix-cortex-a8 -Wl,--no-undefined"
elif [ "$ABI" = "armeabi" ]; then
export CFLAGS="$CFLAGS"
export LDFLAGS="$LDFLAGS -Wl,--fix-cortex-a8 -shared -Wl,--no-undefined"
elif [ "$ABI" = "arm64-v8a" ]; then
export CFLAGS="$CFLAGS -target aarch64-linux-android"
export LDFLAGS="$LDFLAGS -target aarch64-linux-android"
elif [ "$ABI" = "x86" ]; then
export CFLAGS="$CFLAGS -target i686-none-linux-android -march=i686 -msse3 -mstackrealign -mfpmath=sse -fno-stack-protector"
export LDFLAGS="$LDFLAGS -target i686-none-linux-android -march=i686"
@@ -100,7 +100,7 @@ fi
# paths to android SDK, etc
ANDROID_NDK_ROOT=
ANDROID_SDK_ROOT=
ANDROID_API=19
ANDROID_API=23
ANDROID_PLATFORM=android-${ANDROID_API}

################################################################################
@@ -448,23 +448,31 @@ function installAndroidToolchain() {
exit 1
fi

if [ "$ARCH" == "armv7" ]; then
if [ ! -d "$BUILD_DIR/Toolchains/Android/armv7" ]; then
echo $PWD
./make_standalone_toolchain.py \
--install-dir=$BUILD_DIR/Toolchains/Android/$ARCH \
--arch=arm \
--api $ANDROID_API \
--stl=libc++
fi
if [ "$ARCH" == "armv7" ]; then
if [ ! -d "$BUILD_DIR/Toolchains/Android/armv7" ]; then
echo $PWD
./make_standalone_toolchain.py \
--install-dir=$BUILD_DIR/Toolchains/Android/$ARCH \
--arch=arm \
--api $ANDROID_API \
--stl=libc++
fi
elif [ "$ARCH" == "arm64" ]; then
if [ ! -d "$BUILD_DIR/Toolchains/Android/arm64" ]; then
./make_standalone_toolchain.py \
--install-dir=$BUILD_DIR/Toolchains/Android/$ARCH \
--arch=arm64 \
--api $ANDROID_API \
--stl=libc++
fi
elif [ "$ARCH" == "x86" ]; then
if [ ! -d "$BUILD_DIR/Toolchains/Android/x86" ]; then
./make_standalone_toolchain.py \
--install-dir=$BUILD_DIR/Toolchains/Android/$ARCH \
--arch=x86 \
if [ ! -d "$BUILD_DIR/Toolchains/Android/x86" ]; then
./make_standalone_toolchain.py \
--install-dir=$BUILD_DIR/Toolchains/Android/$ARCH \
--arch=x86 \
--api $ANDROID_API \
--stl=libc++
fi
--stl=libc++
fi
fi

cd $WD
@@ -1203,7 +1211,7 @@ fi
echoVerbose "Build type: $TYPE"

# check if we have a valid arch
if [ $ARCH != 32 -a $ARCH != 64 -a $ARCH != armv7 -a $ARCH != x86 ] ; then
if [ $ARCH != 32 -a $ARCH != 64 -a $ARCH != armv7 -a $ARCH != arm64 -a $ARCH != x86 ] ; then
echoError " Invalid architecture: $ARCH"
exit 1
fi
@@ -1251,10 +1259,12 @@ if [[ "$TYPE" == "android" ]] ; then
exit 1
fi
if [ "$ARCH" == "armv7" ]; then
echo setting arch to armv7
ABI=armeabi-v7a
echo setting arch to armv7
ABI=armeabi-v7a
elif [ "$ARCH" == "arm64" ]; then
ABI=arm64-v8a
elif [ "$ARCH" == "x86" ]; then
ABI=x86
ABI=x86
fi
fi

@@ -305,7 +305,12 @@ function build() {

local BUILD_TO_DIR=$BUILD_DIR/FreeImage_patched/build/$TYPE/$ABI
source ../../android_configure.sh $ABI
# export CFLAGS="$CFLAGS -I${NDK_ROOT}/sysroot/usr/include/${ANDROID_PREFIX} -I${NDK_ROOT}/sysroot/usr/include/"

if [ "$ARCH" == "arm64" ] ; then
CFLAGS="$CFLAGS -DPNG_ARM_NEON_OPT=0"
fi

# export CFLAGS="$CFLAGS -I${NDK_ROOT}/sysroot/usr/include/${ANDROID_PREFIX} -I${NDK_ROOT}/sysroot/usr/include/"
export CC="$CC $CFLAGS $LDFLAGS"
export CXX="$CXX $CFLAGS $LDFLAGS"
make clean -f Makefile.gnu
@@ -165,6 +165,24 @@ function build() {
-DANDROID_NATIVE_API_LEVEL=$ANDROID_PLATFORM
-DANDROID_FORCE_ARM_BUILD=TRUE
-DCMAKE_INSTALL_PREFIX=install"

elif [ "$ABI" == "arm64-v8a" ]; then
export HOST=aarch64-linux-android
local buildOpts="--build build/$TYPE
-DBUILD_SHARED_LIBS=OFF
-DASSIMP_BUILD_STATIC_LIB=1
-DASSIMP_BUILD_TESTS=0
-DASSIMP_BUILD_SAMPLES=0
-DASSIMP_ENABLE_BOOST_WORKAROUND=1
-DASSIMP_BUILD_3MF_IMPORTER=0
-DANDROID_NDK=$NDK_ROOT
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE_TOOLCHAIN
-DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI=$ABI
-DANDROID_STL=c++_static
-DANDROID_NATIVE_API_LEVEL=$ANDROID_PLATFORM
-DANDROID_FORCE_ARM_BUILD=TRUE
-DCMAKE_INSTALL_PREFIX=install"
elif [ "$ABI" == "x86" ]; then
export HOST=x86-linux-android
local buildOpts="--build build/$TYPE
@@ -186,7 +204,7 @@ function build() {

# -DASSIMP_BUILD_STL_IMPORTER=0
# -DASSIMP_BUILD_BLEND_IMPORTER=0

rm -rf build_android
mkdir -p build_android
cd build_android
cmake -G 'Unix Makefiles' $buildOpts -DCMAKE_C_FLAGS="-O3 -DNDEBUG ${CFLAGS}" -DCMAKE_CXX_FLAGS="-O3 -DNDEBUG ${CFLAGS}" -DCMAKE_LD_FLAGS="$LDFLAGS" ..
@@ -8,7 +8,7 @@
FORMULA_TYPES=( "osx" "ios" "tvos" "android" "emscripten" "vs" )

# define the version
VERSION=1.64.0
VERSION=1.65.0
VERSION_UNDERSCORES="$(echo "$VERSION" | sed 's/\./_/g')"
TARBALL="boost_${VERSION_UNDERSCORES}.tar.gz"

@@ -64,6 +64,8 @@ function build() {

if [ "$ARCH" == "armv7" ]; then
export HOST=armv7a-linux-android
elif [ "$ARCH" == "arm64" ]; then
export HOST=aarch64-linux-android
elif [ "$ARCH" == "x86" ]; then
export HOST=x86-linux-android
fi
@@ -18,7 +18,8 @@ GIT_TAG=VER-2-7

# download the source code and unpack it into LIB_NAME
function download() {
wget --quiet --no-check-certificate https://sourceforge.net/projects/freetype/files/freetype2/$VER/freetype-$VER.tar.gz/download -O freetype-$VER.tar.gz
wget --quiet --no-check-certificate https://download.savannah.gnu.org/releases/freetype/freetype-$VER.tar.gz -O freetype-$VER.tar.gz

tar -xzf freetype-$VER.tar.gz
mv freetype-$VER freetype
rm freetype*.tar.gz
@@ -345,6 +346,8 @@ function build() {
source ../../android_configure.sh $ABI
if [ "$ARCH" == "armv7" ]; then
HOST=armv7a-linux-android
elif [ "$ARCH" == "arm64" ]; then
HOST=aarch64-linux-android
elif [ "$ARCH" == "x86" ]; then
HOST=x86-linux-android
fi
@@ -17,12 +17,13 @@ function download() {
# wget -nv https://github.com/g-truc/glm/releases/download/$VER/glm-$VER.zip
# unzip glm-$VER.zip
git clone --branch $GIT_TAG --depth=1 $GIT_URL
cd glm
git apply $FORMULA_DIR/gcc73.patch
}

# prepare the build environment, executed inside the lib src dir
function prepare() {
cd glm
git apply $FORMULA_DIR/gcc73.patch
echo
}

# executed inside the lib src dir
@@ -52,6 +52,8 @@ function build() {
source ../../android_configure.sh $ABI
if [ "$ARCH" == "armv7" ]; then
export HOST=armv7a-linux-android
elif [ "$ARCH" == "arm64" ]; then
export HOST=aarch64-linux-android
elif [ "$ARCH" == "x86" ]; then
export HOST=x86-linux-android
fi
@@ -396,6 +396,9 @@ function build() {
if [ "$ABI" = "armeabi-v7a" ] || [ "$ABI" = "armeabi" ]; then
local BUILD_FOLDER="build_android_arm"
local BUILD_SCRIPT="cmake_android_arm.sh"
elif [ "$ABI" = "arm64-v8a" ]; then
local BUILD_FOLDER="build_android_arm64"
local BUILD_SCRIPT="cmake_android_arm64.sh"
elif [ "$ABI" = "x86" ]; then
local BUILD_FOLDER="build_android_x86"
local BUILD_SCRIPT="cmake_android_x86.sh"
@@ -631,6 +634,8 @@ function copy() {
elif [ "$TYPE" == "android" ]; then
if [ $ABI = armeabi-v7a ] || [ $ABI = armeabi ]; then
local BUILD_FOLDER="build_android_arm"
elif [ $ABI = arm64-v8a ]; then
local BUILD_FOLDER="build_android_arm64"
elif [ $ABI = x86 ]; then
local BUILD_FOLDER="build_android_x86"
fi

0 comments on commit 16638ab

Please sign in to comment.
You can’t perform that action at this time.