diff options
-rwxr-xr-x | make/gluegen-properties.xml | 7 | ||||
-rw-r--r-- | make/jogamp-androidtasks.xml | 10 | ||||
-rwxr-xr-x | make/jogamp-env.xml | 8 | ||||
-rw-r--r-- | make/lib/gluegen-cpptasks-android-aarch64.xml | 100 | ||||
-rwxr-xr-x | make/scripts/make.gluegen.all.android-aarch64-cross.sh | 46 | ||||
-rw-r--r-- | make/scripts/setenv-android-tools.sh | 349 |
6 files changed, 375 insertions, 145 deletions
diff --git a/make/gluegen-properties.xml b/make/gluegen-properties.xml index 54fbc8c..2f061fc 100755 --- a/make/gluegen-properties.xml +++ b/make/gluegen-properties.xml @@ -57,10 +57,9 @@ <property name="ant-junit4.jar" value="${ant.home}/lib/ant-junit4.jar" /> <property name="semver.jar" value="${gluegen.root}/make/lib/semantic-versioning/semver.jar" /> - <property name="android.version" value="9" /> <!-- default - if not set by jogamp-env.xml:jogamp.env.init --> - <property name="android-min.jar" value="${gluegen.root}/make/lib/android-sdk/${android.version}/android.jar" /> - <property name="android-015.jar" value="${gluegen.root}/make/lib/android-sdk/15/android.jar" /> - <property name="android.jar" value="${android-015.jar}" /> + <property name="android.api.level" value="24" /> <!-- default - if not set by jogamp-env.xml:jogamp.env.init --> + <property name="android-min.jar" value="${gluegen.root}/make/lib/android-sdk/${android.api.level}/android.jar" /> + <property name="android.jar" value="${android-min.jar}" /> <condition property="android-jars.available"> <and> <available file="${android-min.jar}"/> diff --git a/make/jogamp-androidtasks.xml b/make/jogamp-androidtasks.xml index 82679c4..172da7b 100644 --- a/make/jogamp-androidtasks.xml +++ b/make/jogamp-androidtasks.xml @@ -180,14 +180,6 @@ <arg line="${m.aapt.build.apk}/temp/classes"/> </exec> - <path id="android.antlibs"> - <pathelement path="${env.ANDROID_HOME}/tools/lib/anttasks.jar" /> - <pathelement path="${env.ANDROID_HOME}/tools/lib/sdklib.jar" /> - <pathelement path="${env.ANDROID_HOME}/tools/lib/androidprefs.jar" /> - <pathelement path="${env.ANDROID_HOME}/tools/lib/apkbuilder.jar" /> - <pathelement path="${env.ANDROID_HOME}/tools/lib/jarutils.jar" /> - </path> - <echo>aapt.signed ${m.aapt.apkbasename}: packaging</echo> <exec dir="." executable="aapt" logError="true" failonerror="true" failifexecutionfails="true"> <arg line="package"/> @@ -282,7 +274,7 @@ </exec> <echo>aapt.signed ${m.aapt.apkbasename}: zip aligning</echo> - <exec dir="." executable="${env.ANDROID_HOME}/build-tools/${env.ANDROID_BUILD_TOOLS_VERSION}/zipalign" failonerror="true"> + <exec dir="." executable="zipalign" failonerror="true"> <arg line="-v" /> <arg value="-f" /> <arg value="4" /> diff --git a/make/jogamp-env.xml b/make/jogamp-env.xml index 070c702..332554e 100755 --- a/make/jogamp-env.xml +++ b/make/jogamp-env.xml @@ -11,7 +11,7 @@ Official production builds are performed _on_ OpenJDK 11 and a Java JDK 11 or greater is required! - Android 7 API level 24 supports Java 1.8, + Android 7.0 Nougat, API level 24 supports Java 1.8, see https://developer.android.com/studio/write/java8-support Target Java 8 baseline is chosen today, June 2019, @@ -142,9 +142,9 @@ </not> </condition> - <condition property="android.version" value="${env.ANDROID_VERSION}" else="24"> + <condition property="android.api.level" value="${env.ANDROID_API_LEVEL}" else="24"> <not> - <equals arg1="${env.ANDROID_VERSION}" arg2="$${env.ANDROID_VERSION}" casesensitive="true" /> + <equals arg1="${env.ANDROID_API_LEVEL}" arg2="$${env.ANDROID_API_LEVEL}" casesensitive="true" /> </not> </condition> @@ -237,7 +237,7 @@ <echo message="build.archiveon ${build.archiveon}"/> <echo message="build.node.name ${build.node.name}"/> - <echo message="android.version ${android.version}"/> + <echo message="android.api.level ${android.api.level}"/> <echo message="junit.run.arg0 ${junit.run.arg0}"/> <echo message="junit.run.arg1 ${junit.run.arg1}"/> diff --git a/make/lib/gluegen-cpptasks-android-aarch64.xml b/make/lib/gluegen-cpptasks-android-aarch64.xml index 1daa201..4b6401b 100644 --- a/make/lib/gluegen-cpptasks-android-aarch64.xml +++ b/make/lib/gluegen-cpptasks-android-aarch64.xml @@ -23,7 +23,7 @@ <property name="isAndroidARM64" value="true" /> <property name="jvmDataModel.arg" value="-Djnlp.no.jvm.data.model.set=true" /> <property name="isCrosscompilation" value="true" /> - <property name="android.abi" value="arm64-v8a" /> + <property name="android.abi" value="${env.ANDROID_ABI}" /> <!-- arm64-v8a --> <property name="isAbiEabiGnuArmel" value="true" /> <echo message="gluegen.cpptasks.detect.os.custom: GLUEGEN_CPPTASKS_FILE 'gluegen-cpptasks-android-aarch64' done"/> </target> @@ -32,24 +32,27 @@ <target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir,declare.linux.android"> <echo message="Custom forced compiler Android NDK, linker.cfg.android" /> - <compiler id="compiler.cfg.android" name="gcc"> - <compilerarg value="--sysroot=${TARGET_PLATFORM_SYSROOT}" /> - <!-- The default search dirs for 'gcc from $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin will not find - subprograms properly (see gcc -print-search-dirs). Not sure if this is a bug in the NDK - or not. Need to explicitly indicate where subprograms are with -B. - NOTE: This is not necessary if using '$TARGET_TRIPLE-gcc' from $NDK_TOOLCHAIN_ROOT/bin. --> - <compilerarg value="-B${env.NDK_TOOLCHAIN_ROOT}/libexec/gcc/${env.TARGET_TRIPLE}/${env.GCC_VERSION}" /> + <compiler id="compiler.cfg.android" name="clang"> + <compilerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> + + <!-- compilerarg value="-v" / --> <compilerarg value="-fpic" /> <!-- compilerarg value="-fPIE" / --> <!-- not for shared libs, won't produce symbols --> <!-- compilerarg value="-pie" / --> <!-- not for shared libs, won't produce symbols --> + + <!-- from sdk cmake start --> + <compilerarg value="-fdata-sections" /> <compilerarg value="-ffunction-sections" /> <compilerarg value="-funwind-tables" /> - <compilerarg value="-fstack-protector" /> + <compilerarg value="-fstack-protector-strong" /> <!-- compilerarg value="-no-canonical-prefixes" / --> <!-- will disallow creating shared library --> - <compilerarg value="-Wa,--noexecstack" /> + <!-- from sdk cmake end --> + <compilerarg value="-Wa,--noexecstack" /> + <compilerarg value="-target" /> + <compilerarg value="${env.ANDROID_LLVM_TRIPLE}" /> <!-- aarch64-none-linux-android --> <!-- compilerarg value="-mabi=lp64" /> <compilerarg value="-mlittle-endian" /> <compilerarg value="-march=armv8-a" / --> @@ -60,15 +63,15 @@ <!-- compilerarg value="-g" unless="c.compiler.use-debug" / --> <compilerarg value="-fomit-frame-pointer" unless="c.compiler.use-debug"/> <compilerarg value="-fstrict-aliasing" unless="c.compiler.use-debug"/> - <compilerarg value="-funswitch-loops" unless="c.compiler.use-debug"/> - <compilerarg value="-finline-limit=300" unless="c.compiler.use-debug"/> + <!-- compilerarg value="-funswitch-loops" unless="c.compiler.use-debug"/ not supported --> + <!-- compilerarg value="-finline-limit=300" unless="c.compiler.use-debug"/ not supported --> <compilerarg value="-O0" if="c.compiler.use-debug" /> <compilerarg value="-g" if="c.compiler.use-debug" /> <compilerarg value="-fno-omit-frame-pointer" if="c.compiler.use-debug" /> <compilerarg value="-fno-strict-aliasing" if="c.compiler.use-debug" /> - <includepath path="${env.NDK_TOOLCHAIN_ROOT}/lib/gcc/${env.TARGET_TRIPLE}/${env.GCC_VERSION}/include" /> <!-- for stdarg.h --> + <!-- includepath path="${env.ANDROID_TOOLCHAIN_SYSROOT_INC}" / --> <defineset> <define name="__unix__" /> <!-- define name="__ARM_ARCH_5__" /> @@ -85,39 +88,44 @@ </defineset> </compiler> - <linker id="linker.cfg.android" name="gcc"> - <linkerarg value="--sysroot=${TARGET_PLATFORM_SYSROOT}" /> - - <linkerarg value="-fpic" /> - <!-- linkerarg value="-fPIE" / --> <!-- not for shared libs, won't produce symbols --> - <!-- linkerarg value="-pie" / --> <!-- not for shared libs, won't produce symbols --> - <!-- linkerarg value="-no-canonical-prefixes" / --> <!-- will disallow creating shared library --> - - <linkerarg value="-fno-use-linker-plugin" /> - - <!-- linkerarg value="-mabi=lp64" /> - <linkerarg value="-mlittle-endian" /> - <linkerarg value="-march=armv8-a" / --> - <!-- linkerarg value="-mfloat-abi=softfp" / --> - - <linkerarg value="-nostdlib" /> - <linkerarg value="-Bdynamic" /> - <linkerarg value="-Wl,-dynamic-linker,/system/bin/linker" /> - <linkerarg value="-Wl,-z,nocopyreloc" /> - - <linkerarg value="--demangle" /> - <linkerarg value="--gc-sections" /> - <linkerarg value="--no-undefined" /> - <linkerarg value="-static-libgcc" if="isGCC"/> - <linkerarg value="-static-libstdc++" if="isGCC"/> - <!-- The gcc from $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin needs to be told - where to find libgcc as the default location (gcc -print-search-dirs) - is not correct. Not sure if this is a bug in the NDK or not. We also - enforce that libgcc is linked after source files but before other shared - libraries. --> - <libset dir="${env.NDK_TOOLCHAIN_ROOT}/lib/gcc/${env.TARGET_TRIPLE}/${env.GCC_VERSION}" libs="gcc" /> - <!-- libset libs="c,m,dl,log" / --> - <libset libs="c,m,dl" /> + <linker id="linker.cfg.android" name="clang"> + <linkerarg value="--sysroot=${env.ANDROID_TOOLCHAIN_SYSROOT}" /> + <!-- linkerarg value="-Wl,-L,${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_0}" / --> + <linkerarg value="-Wl,-L,${env.ANDROID_TOOLCHAIN_SYSROOT_LIB_1}" /> + + <!-- linkerarg value="-v" / --> + + <linkerarg value="-fpic" /> + <!-- linkerarg value="-fPIE" / --> <!-- not for shared libs, won't produce symbols --> + <!-- linkerarg value="-pie" / --> <!-- not for shared libs, won't produce symbols --> + <!-- linkerarg value="-no-canonical-prefixes" / --> <!-- will disallow creating shared library --> + + <!-- from sdk cmake start --> + <linkerarg value="-Wl,--build-id" /> + <linkerarg value="-Wl,--warn-shared-textrel" /> + <!-- linkerarg value="-Wl,- -fatal-warnings" / --> + <!-- from sdk cmake end --> + + <linkerarg value="-fno-use-linker-plugin" /> + + <!-- linkerarg value="-mabi=lp64" /> + <linkerarg value="-mlittle-endian" /> + <linkerarg value="-march=armv8-a" / --> + <!-- linkerarg value="-mfloat-abi=softfp" / --> + + <linkerarg value="-nostdlib" /> + <linkerarg value="-Bdynamic" /> + <linkerarg value="-Wl,-dynamic-linker,/system/bin/linker" /> + <linkerarg value="-Wl,-z,nocopyreloc" /> + + <linkerarg value="--demangle" /> + <linkerarg value="--gc-sections" /> + <linkerarg value="--no-undefined" /> + <linkerarg value="-static-libgcc" if="isGCC"/> + <linkerarg value="-static-libstdc++" if="isGCC"/> + + <!-- libset libs="c,m,dl,log" / --> + <libset libs="c,m,dl" /> </linker> </target> diff --git a/make/scripts/make.gluegen.all.android-aarch64-cross.sh b/make/scripts/make.gluegen.all.android-aarch64-cross.sh index 32fea6d..78ccb08 100755 --- a/make/scripts/make.gluegen.all.android-aarch64-cross.sh +++ b/make/scripts/make.gluegen.all.android-aarch64-cross.sh @@ -2,14 +2,30 @@ SDIR=`dirname $0` -if [ -e $SDIR/setenv-build-jogamp-x86_64.sh ] ; then - . $SDIR/setenv-build-jogamp-x86_64.sh +if [ -e ${SDIR}/setenv-build-jogamp-x86_64.sh ] ; then + . ${SDIR}/setenv-build-jogamp-x86_64.sh fi -if [ -e $SDIR/setenv-android-tools.sh ] ; then - . $SDIR/setenv-android-tools.sh +LOGF=make.gluegen.all.android-aarch64-cross.log +rm -f ${LOGF} + +export ANDROID_HOME=/opt-linux-x86_64/android-sdk-linux_x86_64 +export ANDROID_API_LEVEL=24 +export ANDROID_HOST_TAG=linux-x86_64 +export ANDROID_ABI=arm64-v8a + +if [ -e ${SDIR}/setenv-android-tools.sh ] ; then + . ${SDIR}/setenv-android-tools.sh >> $LOGF 2>&1 +else + echo "${SDIR}/setenv-android-tools.sh doesn't exist!" 2>&1 | tee -a ${LOGF} + exit 1 fi +export GLUEGEN_CPPTASKS_FILE="lib/gluegen-cpptasks-android-aarch64.xml" +export PATH=${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_NAME}/bin:${ANDROID_TOOLCHAIN_ROOT}/bin:${ANDROID_HOME}/platform-tools:${ANDROID_BUILDTOOLS_ROOT}:${PATH} +echo PATH ${PATH} 2>&1 | tee -a ${LOGF} +echo clang `which clang` 2>&1 | tee -a ${LOGF} + export NODE_LABEL=. export HOST_UID=jogamp @@ -26,36 +42,18 @@ export TARGET_ADB_PORT=5555 export TARGET_ROOT=/data/projects export TARGET_ANT_HOME=/usr/share/ant -export ANDROID_VERSION=24 export SOURCE_LEVEL=1.8 export TARGET_LEVEL=1.8 export TARGET_RT_JAR=/opt-share/jre1.8.0_212/lib/rt.jar -export GCC_VERSION=4.9 -HOST_ARCH=linux-x86_64 -export TARGET_TRIPLE=aarch64-linux-android - -export NDK_TOOLCHAIN_ROOT=$NDK_ROOT/toolchains/${TARGET_TRIPLE}-${GCC_VERSION}/prebuilt/${HOST_ARCH} -export TARGET_PLATFORM_SYSROOT=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-arm64 - -# Need to add toolchain bins to the PATH. -# May need to create symbolic links within $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin -# cd $NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin -# ln -s ../../bin/aarch64-linux-android-gcc gcc -export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION:$PATH" - -export GLUEGEN_CPPTASKS_FILE="lib/gluegen-cpptasks-android-aarch64.xml" - #export JUNIT_DISABLED="true" #export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" -echo PATH $PATH 2>&1 | tee make.gluegen.all.android-aarch64-cross.log -echo gcc `which gcc` 2>&1 | tee -a make.gluegen.all.android-aarch64-cross.log - #export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" #BUILD_ARCHIVE=true \ ant \ -Drootrel.build=build-android-aarch64 \ - $* 2>&1 | tee -a make.gluegen.all.android-aarch64-cross.log + -Dgcc.compat.compiler=clang \ + $* 2>&1 | tee -a ${LOGF} diff --git a/make/scripts/setenv-android-tools.sh b/make/scripts/setenv-android-tools.sh index a6384fa..b0e6144 100644 --- a/make/scripts/setenv-android-tools.sh +++ b/make/scripts/setenv-android-tools.sh @@ -1,83 +1,316 @@ #! /bin/sh +# Aligned with Android SDK build-tools 29 and NDK 20 as of 2019-12-10 +# +# As it is no more easily achievable to download the complete SDK +# separately, I used Android-Studio to fetch all parts incl. the NDK. +# Thereafter I copied ~/Android/Sdk -> /opt-linux-x86_64/android-sdk-linux_x86_64 +# which I also use for the official crosscompilation. +# +# Variable names borrowed from ~/Android/Sdk/ndk/20.1.5948944/build/cmake/android.toolchain.cmake +# We only use ANDROID_API_LEVEL instead of ANDROID_PLATFORM_LEVEL, as it describes the API level. +# +# +# User should set environment variables: +# ========================================== +# +# - ANDROID_HOME - defaults to one of +# ~/Android/Sdk +# /opt-linux-x86_64/android-sdk-linux_x86_64 +# /opt/android-sdk-linux_x86_64 +# /usr/local/android-sdk-linux_x86_64 +# +# - ANDROID_API_LEVEL - defaults to 24 +# +# - ANDROID_HOST_TAG - defaults to linux-x86_64 +# +# - ANDROID_ABI - defaults to x86_64, one of +# armeabi-v7a +# arm64-v8a +# x86_64 +# x86 +# +# Following environment variables will be set +# ============================================ +# +# - ANDROID_SYSROOT_ABI +# - ANDROID_TOOLCHAIN_NAME +# - ANDROID_LLVM_TRIPLE +# - ANDROID_BUILD_TOOLS_VERSION +# - ANDROID_NDK +# - ANDROID_BUILDTOOLS_ROOT +# - ANDROID_TOOLCHAIN_ROOT +# - ANDROID_TOOLCHAIN_SYSROOT +# - ANDROID_TOOLCHAIN_SYSROOT_INC +# - ANDROID_TOOLCHAIN_SYSROOT_LIB_0 +# - ANDROID_TOOLCHAIN_SYSROOT_LIB_1 +# +# Android Studio SDK + NDK Filesystem Layout (official) +# +# ~/Android/Sdk/ +# ~/Android/Sdk/build-tools/29.0.2/ +# ~/Android/Sdk/build-tools/29.0.2/zipalign (*) +# ~/Android/Sdk/ndk/ +# ~/Android/Sdk/ndk/20.1.5948944/sysroot/ (gcc) +# ~/Android/Sdk/ndk/20.1.5948944/sysroot/usr/include/ (gcc) +# ~/Android/Sdk/ndk/20.1.5948944/sysroot/usr/lib/aarch64-linux-android/libc.a (gcc) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/ +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld (gcc) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld (gcc) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/ +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld (*) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/clang (*) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc.a (*) +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libc.a (*) +# +# (*) tested by this script +# +# Having +# ANDROID_HOME=~/Android/Sdk +# ANDROID_API_LEVEL 24 +# ANDROID_HOST_TAG linux-x86_64 +# ANDROID_ABI arm64-v8a +# Using derived values of +# ANDROID_BUILD_TOOLS_VERSION=29.0.2 +# ANDROID_NDK_VERSION=20.1.5948944 +# ANDROID_TOOLCHAIN_NAME aarch64-linux-android + echo $0 -echo Presets -echo NDK_ROOT $NDK_ROOT -echo ANDROID_HOME $ANDROID_HOME -echo ANDROID_BUILD_TOOLS_VERSION $ANDROID_BUILD_TOOLS_VERSION +NDK_TOOLCHAIN_VERSION=clang +echo "Setting NDK_TOOLCHAIN_VERSION to ${NDK_TOOLCHAIN_VERSION} default!" -if [ -z "$NDK_ROOT" ] ; then - # - # Generic android-ndk - # - if [ -e /usr/local/android-ndk ] ; then - NDK_ROOT=/usr/local/android-ndk - elif [ -e /opt-linux-x86_64/android-ndk ] ; then - NDK_ROOT=/opt-linux-x86_64/android-ndk - elif [ -e /opt-linux-x86/android-ndk ] ; then - NDK_ROOT=/opt-linux-x86/android-ndk - elif [ -e /opt/android-ndk ] ; then - NDK_ROOT=/opt/android-ndk - # - # Specific android-ndk-r10d - # - elif [ -e /usr/local/android-ndk-r10d ] ; then - NDK_ROOT=/usr/local/android-ndk-r10d - elif [ -e /opt-linux-x86_64/android-ndk-r10d ] ; then - NDK_ROOT=/opt-linux-x86_64/android-ndk-r10d - elif [ -e /opt-linux-x86/android-ndk-r10d ] ; then - NDK_ROOT=/opt-linux-x86/android-ndk-r10d - elif [ -e /opt/android-ndk-r10d ] ; then - NDK_ROOT=/opt/android-ndk-r10d - else - echo NDK_ROOT is not specified and does not exist in default locations - exit 1 - fi -elif [ ! -e $NDK_ROOT ] ; then - echo NDK_ROOT $NDK_ROOT does not exist +if [ -z "${ANDROID_API_LEVEL}" ] ; then + ANDROID_API_LEVEL=24 + echo "Setting undefined ANDROID_API_LEVEL to ${ANDROID_API_LEVEL} default!" +fi +if [ -z "${ANDROID_HOST_TAG}" ] ; then + ANDROID_HOST_TAG=linux-x86_64 + echo "Setting undefined ANDROID_HOST_TAG to ${ANDROID_HOST_TAG} default!" +fi + +if [ -z "${ANDROID_ABI}" ] ; then + ANDROID_ABI=x86_64 + echo "Setting undefined ANDROID_ABI to ${ANDROID_ABI} default!" +fi +if [ "${ANDROID_ABI}" = "armeabi-v7a" ] ; then + ANDROID_SYSROOT_ABI=arm + #CMAKE_SYSTEM_PROCESSOR=armv7-a + ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi + ANDROID_LLVM_TRIPLE=armv7-none-linux-androideabi +elif [ "${ANDROID_ABI}" = "arm64-v8a" ] ; then + ANDROID_SYSROOT_ABI=arm64 + #CMAKE_SYSTEM_PROCESSOR=aarch64 + ANDROID_TOOLCHAIN_NAME=aarch64-linux-android + ANDROID_LLVM_TRIPLE=aarch64-none-linux-android +elif [ "${ANDROID_ABI}" = "x86_64" ] ; then + ANDROID_SYSROOT_ABI=x86_64 + #CMAKE_SYSTEM_PROCESSOR=x86_64 + ANDROID_TOOLCHAIN_NAME=x86_64-linux-android + ANDROID_LLVM_TRIPLE=x86_64-none-linux-android +elif [ "${ANDROID_ABI}" = "x86" ] ; then + ANDROID_SYSROOT_ABI=x86 + #CMAKE_SYSTEM_PROCESSOR=i686 + ANDROID_TOOLCHAIN_NAME=i686-linux-android + ANDROID_LLVM_TRIPLE=i686-none-linux-android +else + echo "ANDROID_ABI is ${ANDROID_ABI} and not supported!" exit 1 fi -export NDK_ROOT -if [ -z "$ANDROID_HOME" ] ; then - if [ -e /usr/local/android-sdk-linux_x86 ] ; then - ANDROID_HOME=/usr/local/android-sdk-linux_x86 +echo "Preset-0 (user)" +echo ANDROID_HOME ${ANDROID_HOME} +echo ANDROID_API_LEVEL ${ANDROID_API_LEVEL} +echo ANDROID_HOST_TAG ${ANDROID_HOST_TAG} +echo ANDROID_ABI ${ANDROID_ABI} +echo +echo Preset-1 +echo NDK_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION} +echo ANDROID_SYSROOT_ABI ${ANDROID_SYSROOT_ABI} +echo ANDROID_TOOLCHAIN_NAME ${ANDROID_TOOLCHAIN_NAME} +echo "ANDROID_LLVM_TRIPLE ${ANDROID_LLVM_TRIPLE} (compiler target)" +echo ANDROID_BUILD_TOOLS_VERSION ${ANDROID_BUILD_TOOLS_VERSION} +echo ANDROID_NDK ${ANDROID_NDK} +echo +echo Preset-2 +echo ANDROID_BUILDTOOLS_ROOT ${ANDROID_BUILDTOOLS_ROOT} +echo ANDROID_TOOLCHAIN_ROOT ${ANDROID_TOOLCHAIN_ROOT} +echo ANDROID_TOOLCHAIN_SYSROOT ${ANDROID_TOOLCHAIN_SYSROOT} +echo ANDROID_TOOLCHAIN_SYSROOT_INC ${ANDROID_TOOLCHAIN_SYSROOT_INC} +echo ANDROID_TOOLCHAIN_SYSROOT_LIB_0 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_0} +echo ANDROID_TOOLCHAIN_SYSROOT_LIB_1 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_1} +echo + +check_exists() { + if [ ! -e "$1" ] ; then + echo "$1" does not exist + exit 1 + fi + return 0 +} + +if [ -z "${ANDROID_HOME}" ] ; then + if [ -e ${HOME}/Android/Sdk ] ; then + ANDROID_HOME=${HOME}/Android/Sdk elif [ -e /opt-linux-x86_64/android-sdk-linux_x86_64 ] ; then - ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 - elif [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then - ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 + ANDROID_HOME=/opt-linux-x86_64/android-sdk-linux_x86_64 elif [ -e /opt/android-sdk-linux_x86_64 ] ; then ANDROID_HOME=/opt/android-sdk-linux_x86_64 - elif [ -e /opt/android-sdk-linux_x86 ] ; then - ANDROID_HOME=/opt/android-sdk-linux_x86 + elif [ -e /usr/local/android-sdk-linux_x86_64 ] ; then + ANDROID_HOME=/usr/local/android-sdk-linux_x86_64 else echo ANDROID_HOME is not specified and does not exist in default locations exit 1 fi -elif [ ! -e $ANDROID_HOME ] ; then - echo ANDROID_HOME $ANDROID_HOME does not exist +elif [ ! -e ${ANDROID_HOME} ] ; then + echo ANDROID_HOME ${ANDROID_HOME} does not exist exit 1 fi -export ANDROID_HOME -if [ -z "$ANDROID_BUILD_TOOLS_VERSION" ] ; then - if [ -e $ANDROID_HOME/build-tools/21.1.2/zipalign ] ; then - ANDROID_BUILD_TOOLS_VERSION=21.1.2 - elif [ -e $ANDROID_HOME/build-tools/20.0.0/zipalign ] ; then - ANDROID_BUILD_TOOLS_VERSION=20.0.0 - else - echo ANDROID_BUILD_TOOLS_VERSION $ANDROID_HOME/build-tools/ANDROID_BUILD_TOOLS_VERSION/zipalign does not exist in default locations +unset ANDROID_BUILD_TOOLS_VERSION +if [ -z "${ANDROID_BUILD_TOOLS_VERSION}" ] ; then + # basename $(dirname `find /home/sven/Android/Sdk/build-tools -name zipalign | sort -u | tail -n1`) + fzipalign=`find ${ANDROID_HOME}/build-tools -name zipalign | sort -u | tail -n1` + if [ ! -z "${fzipalign}" ] ; then + dzipalign=`dirname ${fzipalign}` + vzipalign=`basename ${dzipalign}` + if [ -e ${ANDROID_HOME}/build-tools/${vzipalign}/zipalign ] ; then + ANDROID_BUILD_TOOLS_VERSION=${vzipalign} + fi + fi + if [ -z "${ANDROID_BUILD_TOOLS_VERSION}" ] ; then + echo ANDROID_BUILD_TOOLS_VERSION ${ANDROID_HOME}/build-tools/ANDROID_BUILD_TOOLS_VERSION/zipalign does not exist + exit 1 + fi +fi + +if [ -z "${ANDROID_NDK}" ] ; then + # + # Generic android-ndk + # + if [ -e ${ANDROID_HOME}/ndk ] ; then + # basename $(dirname `find ndk -name toolchains -a -type d | sort -u | tail -n1`) + d2toolchains=`find ${ANDROID_HOME}/ndk -name toolchains -a -type d | sort -u | tail -n1` + if [ ! -z "${d2toolchains}" ] ; then + dtoolchains=`dirname ${d2toolchains}` + vtoolchains=`basename ${dtoolchains}` + # ~/Android/Sdk/ndk/20.1.5948944/sysroot/usr/lib/aarch64-linux-android/libc.a (*) + if [ -e ${ANDROID_HOME}/ndk/${vtoolchains}/sysroot/usr/lib/aarch64-linux-android/libc.a ] ; then + ANDROID_NDK_VERSION=${vtoolchains} + fi + fi + if [ -z "${ANDROID_NDK_VERSION}" ] ; then + echo ANDROID_NDK_VERSION ${ANDROID_HOME}/ndk/ANDROID_NDK_VERSION/sysroot/usr/lib/aarch64-linux-android/libc.a does not exist + else + ANDROID_NDK=${ANDROID_HOME}/ndk/${vtoolchains} + fi + fi + if [ -z "${ANDROID_NDK}" ] ; then + if [ -e /usr/local/android-ndk ] ; then + ANDROID_NDK=/usr/local/android-ndk + elif [ -e /opt-linux-x86_64/android-ndk ] ; then + ANDROID_NDK=/opt-linux-x86_64/android-ndk + elif [ -e /opt/android-ndk ] ; then + ANDROID_NDK=/opt/android-ndk + fi + fi + if [ -z "${ANDROID_NDK}" ] ; then + echo ANDROID_NDK is not specified and does not exist in default locations exit 1 fi -elif [ ! -e $ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION/zipalign ] ; then - echo ANDROID_BUILD_TOOLS_VERSION $ANDROID_HOME/build-tools/$ANDROID_BUILD_TOOLS_VERSION/zipalign does not exist +fi +if [ ! -e "${ANDROID_NDK}" ] ; then + echo ANDROID_NDK ${ANDROID_NDK} does not exist exit 1 fi + +ANDROID_BUILDTOOLS_ROOT=${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION} +ANDROID_TOOLCHAIN_ROOT=${ANDROID_NDK}/toolchains/llvm/prebuilt/${ANDROID_HOST_TAG} +ANDROID_TOOLCHAIN_SYSROOT=${ANDROID_TOOLCHAIN_ROOT}/sysroot +ANDROID_TOOLCHAIN_SYSROOT_INC=${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/include +ANDROID_TOOLCHAIN_SYSROOT_LIB_0=${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/lib/${ANDROID_TOOLCHAIN_NAME} +ANDROID_TOOLCHAIN_SYSROOT_LIB_1=${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/lib/${ANDROID_TOOLCHAIN_NAME}/${ANDROID_API_LEVEL} + +# ~/Android/Sdk/build-tools/29.0.2/zipalign (*) +check_exists ${ANDROID_BUILDTOOLS_ROOT}/zipalign + +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld (*) +check_exists ${ANDROID_TOOLCHAIN_ROOT}/bin/${ANDROID_TOOLCHAIN_NAME}-ld + +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/bin/clang (*) +check_exists ${ANDROID_TOOLCHAIN_ROOT}/bin/clang + +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc.a (*) +check_exists ${ANDROID_TOOLCHAIN_SYSROOT_LIB_0}/libc.a + +# ~/Android/Sdk/ndk/20.1.5948944/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/24/libc.a (*) +check_exists ${ANDROID_TOOLCHAIN_SYSROOT_LIB_1}/libc.a + +export ANDROID_HOME +export ANDROID_API_LEVEL +export ANDROID_HOST_TAG +export ANDROID_ABI + +export NDK_TOOLCHAIN_VERSION +export ANDROID_SYSROOT_ABI +export ANDROID_TOOLCHAIN_NAME +export ANDROID_LLVM_TRIPLE export ANDROID_BUILD_TOOLS_VERSION +export ANDROID_NDK + +export ANDROID_BUILDTOOLS_ROOT +export ANDROID_TOOLCHAIN_ROOT +export ANDROID_TOOLCHAIN_SYSROOT +export ANDROID_TOOLCHAIN_SYSROOT_INC +export ANDROID_TOOLCHAIN_SYSROOT_LIB_0 +export ANDROID_TOOLCHAIN_SYSROOT_LIB_1 + +echo "Postset-0 (user)" +echo ANDROID_HOME ${ANDROID_HOME} +echo ANDROID_API_LEVEL ${ANDROID_API_LEVEL} +echo ANDROID_HOST_TAG ${ANDROID_HOST_TAG} +echo ANDROID_ABI ${ANDROID_ABI} +echo +echo Postset-1 +echo NDK_TOOLCHAIN_VERSION ${NDK_TOOLCHAIN_VERSION} +echo ANDROID_SYSROOT_ABI ${ANDROID_SYSROOT_ABI} +echo ANDROID_TOOLCHAIN_NAME ${ANDROID_TOOLCHAIN_NAME} +echo "ANDROID_LLVM_TRIPLE ${ANDROID_LLVM_TRIPLE} (compiler target)" +echo ANDROID_BUILD_TOOLS_VERSION ${ANDROID_BUILD_TOOLS_VERSION} +echo ANDROID_NDK ${ANDROID_NDK} +echo +echo Postset-2 +echo ANDROID_BUILDTOOLS_ROOT ${ANDROID_BUILDTOOLS_ROOT} +echo ANDROID_TOOLCHAIN_ROOT ${ANDROID_TOOLCHAIN_ROOT} +echo ANDROID_TOOLCHAIN_SYSROOT ${ANDROID_TOOLCHAIN_SYSROOT} +echo ANDROID_TOOLCHAIN_SYSROOT_INC ${ANDROID_TOOLCHAIN_SYSROOT_INC} +echo ANDROID_TOOLCHAIN_SYSROOT_LIB_0 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_0} +echo ANDROID_TOOLCHAIN_SYSROOT_LIB_1 ${ANDROID_TOOLCHAIN_SYSROOT_LIB_1} +echo + +export -p | grep ANDROID -echo Set -echo NDK_ROOT $NDK_ROOT -echo ANDROID_HOME $ANDROID_HOME -echo ANDROID_BUILD_TOOLS_VERSION $ANDROID_BUILD_TOOLS_VERSION +# +# CC="$ANDROID_NDK/toolchains/llvm/prebuilt/$ANDROID_HOST_TAG/bin/clang -target $ANDROID_LLVM_TRIPLE" +# +## Generic flags. +##list(APPEND ANDROID_COMPILER_FLAGS +# -g +# -DANDROID +# -fdata-sections +# -ffunction-sections +# -funwind-tables +# -fstack-protector-strong +# -no-canonical-prefixes) +#list(APPEND ANDROID_LINKER_FLAGS +# -Wl,--build-id +# -Wl,--warn-shared-textrel +# -Wl,--fatal-warnings) +#list(APPEND ANDROID_LINKER_FLAGS_EXE -Wl,--gc-sections) +# +#list(APPEND ANDROID_COMPILER_FLAGS_RELEASE -O2) +# |