diff options
Diffstat (limited to 'packaging/android/build.sh')
-rwxr-xr-x | packaging/android/build.sh | 90 |
1 files changed, 50 insertions, 40 deletions
diff --git a/packaging/android/build.sh b/packaging/android/build.sh index 81db27488..99addc346 100755 --- a/packaging/android/build.sh +++ b/packaging/android/build.sh @@ -63,7 +63,7 @@ while [ "$#" -gt 0 ] ; do SUBSURFACE_DESKTOP=ON shift ;; - arm|x86) + arm|arm64|x86) ARCH=$1 shift ;; @@ -117,10 +117,17 @@ if [ "$ARCH" = "arm" ] ; then QT_ARCH=armv7 BUILDCHAIN=arm-linux-androideabi OPENSSL_MACHINE=armv7 + ANDROID_ABI=armeabi-v7a +elif [ "$ARCH" = "arm64" ] ; then # requires Qt 5.12 + QT_ARCH=arm64_v8a + BUILDCHAIN=aarch64-linux-android + ANDROID_ABI=arm64-v8a + OPENSSL_MACHINE=aarch64 elif [ "$ARCH" = "x86" ] ; then QT_ARCH=$ARCH BUILDCHAIN=i686-linux-android OPENSSL_MACHINE=i686 + ANDROID_ABI=x86 fi # Verify Qt install and adjust for single-arch Qt install layout @@ -136,21 +143,20 @@ else fi if [ ! -e ndk-"$ARCH" ] ; then - "$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py" --arch="$ARCH" --install-dir=ndk-"$ARCH" --api=16 + "$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py" --arch="$ARCH" --install-dir=ndk-"$ARCH" --api=$ANDROID_PLATFORM_LEVEL fi export BUILDROOT=$PWD export PATH=${BUILDROOT}/ndk-$ARCH/bin:$PATH export PREFIX=${BUILDROOT}/ndk-$ARCH/sysroot/usr export PKG_CONFIG_LIBDIR=$PREFIX/lib/pkgconfig -export CC=${BUILDROOT}/ndk-$ARCH/bin/${BUILDCHAIN}-gcc -export CXX=${BUILDROOT}/ndk-$ARCH/bin/${BUILDCHAIN}-g++ +export CC=${BUILDROOT}/ndk-$ARCH/bin/clang +export CXX=${BUILDROOT}/ndk-$ARCH/bin/clang++ # autoconf seems to get lost without this export SYSROOT=${BUILDROOT}/ndk-$ARCH/sysroot -export CFLAGS=--sysroot=${SYSROOT} -export CPPFLAGS=--sysroot=${SYSROOT} -export CXXFLAGS=--sysroot=${SYSROOT} -# Junk needed for qt-android-cmake -export ANDROID_STANDALONE_TOOLCHAIN=${BUILDROOT}/ndk-$ARCH +export CFLAGS="--sysroot=${SYSROOT} -fPIC" +export CPPFLAGS="--sysroot=${SYSROOT} -fPIC" +export CXXFLAGS="--sysroot=${SYSROOT} -fPIC" + if [ "$PLATFORM" = "Darwin" ] ; then JAVA_HOME=$(/usr/libexec/java_home) export JAVA_HOME @@ -159,7 +165,8 @@ else fi # find qmake -QMAKE=$QT5_ANDROID/android_armv7/bin/qmake +QMAKE=$QT5_ANDROID/android_$QT_ARCH/bin/qmake +echo $QMAKE $QMAKE -query # if we are just doing a quick rebuild, don't bother with any of the dependencies @@ -170,7 +177,7 @@ if [ "$QUICK" = "" ] ; then # build google maps plugin "${SUBSURFACE_SOURCE}"/scripts/get-dep-lib.sh singleAndroid . googlemaps # find qmake - QMAKE=$QT5_ANDROID/android_armv7/bin/qmake + QMAKE=$QT5_ANDROID/android_$QT_ARCH/bin/qmake $QMAKE -query QT_PLUGINS_PATH=$($QMAKE -query QT_INSTALL_PLUGINS) GOOGLEMAPS_BIN=libqtgeoservices_googlemaps.so @@ -228,8 +235,33 @@ if [ "$QUICK" = "" ] ; then make install popd fi + + + "${SUBSURFACE_SOURCE}"/scripts/get-dep-lib.sh singleAndroid . openssl + if [ ! -e "$PKG_CONFIG_LIBDIR/libssl.pc" ] ; then + mkdir -p openssl-build-"$ARCH" + cp -r openssl/* openssl-build-"$ARCH" + pushd openssl-build-"$ARCH" + perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org + perl -pi -e 's/-mandroid//g' Configure + # Use env to make all these temporary, so they don't pollute later builds. + env SYSTEM=android \ + CROSS_COMPILE=${BUILDCHAIN}- \ + MACHINE=$OPENSSL_MACHINE \ + HOSTCC=clang \ + CC=clang \ + ANDROID_DEV="$PREFIX" \ + bash -x ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine no-asm --openssldir="$PREFIX" + # sed -i.bak -e 's/soname=\$\$SHLIB\$\$SHLIB_SOVER\$\$SHLIB_SUFFIX/soname=\$\$SHLIB/g' Makefile.shared + make depend + make + # now fix the reference to libcrypto.so.1.0.0 to be just to libcrypto.so + perl -pi -e 's/libcrypto.so.1.0.0/libcrypto.so\x00\x00\x00\x00\x00\x00/' libssl.so.1.0.0 + make install_sw + popd + fi - "${SUBSURFACE_SOURCE}"/scripts/get-dep-lib.sh singleAndroid . libzip +"${SUBSURFACE_SOURCE}"/scripts/get-dep-lib.sh singleAndroid . libzip if [ ! -e "$PKG_CONFIG_LIBDIR/libzip.pc" ] ; then # libzip expects a predefined macro that isn't there for our compiler pushd libzip @@ -244,6 +276,7 @@ if [ "$QUICK" = "" ] ; then -DCMAKE_C_COMPILER="$CC" \ -DCMAKE_LINKER="$CC" \ -DCMAKE_INSTALL_PREFIX="$PREFIX" \ + -DCMAKE_INSTALL_LIBDIR="lib" \ -DBUILD_SHARED_LIBS=OFF \ ../libzip/ make @@ -251,30 +284,6 @@ if [ "$QUICK" = "" ] ; then popd fi - "${SUBSURFACE_SOURCE}"/scripts/get-dep-lib.sh singleAndroid . openssl - if [ ! -e openssl-build-"$ARCH" ] ; then - mv openssl openssl-build-"$ARCH" - fi - if [ ! -e "$PKG_CONFIG_LIBDIR/libssl.pc" ] ; then - pushd openssl-build-"$ARCH" - perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org - # Use env to make all these temporary, so they don't pollute later builds. - env SYSTEM=android \ - CROSS_COMPILE=${BUILDCHAIN}- \ - MACHINE=$OPENSSL_MACHINE \ - HOSTCC=gcc \ - CC=gcc \ - ANDROID_DEV="$PREFIX" \ - bash -x ./config shared no-ssl2 no-ssl3 no-comp no-hw no-engine --openssldir="$PREFIX" - # sed -i.bak -e 's/soname=\$\$SHLIB\$\$SHLIB_SOVER\$\$SHLIB_SUFFIX/soname=\$\$SHLIB/g' Makefile.shared - make depend - make - # now fix the reference to libcrypto.so.1.0.0 to be just to libcrypto.so - perl -pi -e 's/libcrypto.so.1.0.0/libcrypto.so\x00\x00\x00\x00\x00\x00/' libssl.so.1.0.0 - make install_sw - popd - fi - "${SUBSURFACE_SOURCE}"/scripts/get-dep-lib.sh singleAndroid . libgit2 if [ ! -e "$PKG_CONFIG_LIBDIR/libgit2.pc" ] ; then # We don't want to find the HTTP_Parser package of the build host by mistake @@ -395,14 +404,15 @@ fi PKGCONF=$(which pkg-config) cmake $MOBILE_CMAKE \ - -DPKG_CONFIG_EXECUTABLE="$PKGCONF" \ + -DCMAKE_SYSTEM_NAME="Android" \ + -DANDROID_ABI=$ANDROID_ABI \ + -DANDROID_PLATFORM="$ANDROID_PLATFORM" \ -DQT_ANDROID_SDK_ROOT="$ANDROID_SDK_ROOT" \ -DQT_ANDROID_NDK_ROOT="$ANDROID_NDK_ROOT" \ - -DANDROID_TOOLCHAIN="gcc" \ - -DANDROID_PLATFORM="android-16" \ + -DPKG_CONFIG_EXECUTABLE="$PKGCONF" \ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK_ROOT"/build/cmake/android.toolchain.cmake \ -DQT_ANDROID_CMAKE="$BUILDROOT"/qt-android-cmake/AddQtAndroidApk.cmake \ - -DANDROID_STL="gnustl_shared" \ + -DANDROID_STL="c++_shared" \ -DFORCE_LIBSSH=OFF \ -DLIBDC_FROM_PKGCONFIG=ON \ -DLIBGIT2_FROM_PKGCONFIG=ON \ |