2017-02-06 14:55:32 +00:00
|
|
|
#!/bin/bash -eu
|
2017-01-21 05:41:17 +00:00
|
|
|
|
|
|
|
# run this in the top level folder you want to create Android binaries in
|
|
|
|
#
|
2017-05-31 17:08:56 +00:00
|
|
|
# it seems that with Qt5.7 (and later) and current cmake there is an odd bug where
|
2017-01-21 05:41:17 +00:00
|
|
|
# cmake fails reporting :No known features for CXX compiler "GNU". In that
|
|
|
|
# case simly comment out the "set(property(TARGET Qt5::Core PROPERTY...)"
|
|
|
|
# at line 101 of
|
2018-07-10 05:07:03 +00:00
|
|
|
# Qt/5.7/android_armv7/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake
|
2017-03-20 12:44:19 +00:00
|
|
|
# or at line 95 of
|
|
|
|
# Qt/5.8/android_armv7/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake
|
2017-05-31 17:08:56 +00:00
|
|
|
# or at line 105 of
|
|
|
|
# Qt/5.9/android_armv7/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake
|
|
|
|
# (this script tries to do this automatically)
|
2017-01-21 05:41:17 +00:00
|
|
|
|
2018-07-10 05:07:03 +00:00
|
|
|
exec 1> >(tee ./build.log) 2>&1
|
|
|
|
|
|
|
|
USE_X=$(case $- in *x*) echo "-x" ;; esac)
|
|
|
|
|
2018-12-22 17:13:20 +00:00
|
|
|
# deal with the command line arguments
|
|
|
|
while [[ $# -gt 0 ]] ; do
|
|
|
|
arg="$1"
|
|
|
|
case $arg in
|
|
|
|
-prep-only)
|
|
|
|
# only download the dependencies, don't build
|
|
|
|
PREP_ONLY="1"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown command line argument $arg"
|
|
|
|
echo "Usage: $0 [-prep-only]"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2018-07-10 05:07:03 +00:00
|
|
|
# these are the current versions for Qt, Android SDK & NDK:
|
2018-12-22 17:45:33 +00:00
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
|
|
|
|
source "$SCRIPTDIR"/variables.sh
|
2018-07-10 05:07:03 +00:00
|
|
|
|
2017-01-21 05:41:17 +00:00
|
|
|
PLATFORM=$(uname)
|
|
|
|
|
2018-12-22 17:45:33 +00:00
|
|
|
export SUBSURFACE_SOURCE="$SCRIPTDIR"/../..
|
2017-02-06 14:55:40 +00:00
|
|
|
|
2017-02-08 17:03:34 +00:00
|
|
|
if [ "$PLATFORM" = Linux ] ; then
|
2017-05-31 17:08:56 +00:00
|
|
|
QT_BINARIES=qt-opensource-linux-x64-${LATEST_QT}.run
|
2017-01-21 05:41:17 +00:00
|
|
|
NDK_BINARIES=${ANDROID_NDK}-linux-x86_64.zip
|
2017-11-15 11:22:36 +00:00
|
|
|
SDK_TOOLS=sdk-tools-linux-${SDK_VERSION}.zip
|
2017-01-21 05:41:17 +00:00
|
|
|
else
|
|
|
|
echo "only on Linux so far"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-02-04 01:27:45 +00:00
|
|
|
# make sure we have the required commands installed
|
2017-02-08 17:03:34 +00:00
|
|
|
MISSING=
|
2018-05-14 20:54:29 +00:00
|
|
|
for i in git cmake autoconf libtool java wget unzip; do
|
2017-02-08 17:03:22 +00:00
|
|
|
command -v $i >/dev/null ||
|
2017-02-08 17:03:34 +00:00
|
|
|
if [ $i = libtool ] ; then
|
2017-02-04 01:27:45 +00:00
|
|
|
MISSING="${MISSING}libtool-bin "
|
2017-02-08 17:03:34 +00:00
|
|
|
elif [ $i = java ] ; then
|
2017-02-04 01:27:45 +00:00
|
|
|
MISSING="${MISSING}openjdk-8-jdk "
|
|
|
|
else
|
|
|
|
MISSING="${MISSING}${i} "
|
|
|
|
fi
|
|
|
|
done
|
2017-02-08 17:03:49 +00:00
|
|
|
if [ "$MISSING" ] ; then
|
2017-02-04 01:27:45 +00:00
|
|
|
echo "The following packages are missing: $MISSING"
|
|
|
|
echo "Please install via your package manager."
|
2017-02-06 14:55:31 +00:00
|
|
|
exit 1
|
2017-02-04 01:27:45 +00:00
|
|
|
fi
|
|
|
|
|
2017-12-24 20:58:29 +00:00
|
|
|
# first we need to get the Android SDK and NDK
|
2018-07-04 05:51:59 +00:00
|
|
|
if [ ! -d "$ANDROID_NDK" ] ; then
|
|
|
|
if [ ! -f "$NDK_BINARIES" ] ; then
|
2018-12-24 19:28:10 +00:00
|
|
|
wget -q https://dl.google.com/android/repository/"$NDK_BINARIES"
|
2017-01-21 05:41:17 +00:00
|
|
|
fi
|
2018-07-04 05:51:59 +00:00
|
|
|
unzip -q "$NDK_BINARIES"
|
2017-01-21 05:41:17 +00:00
|
|
|
fi
|
|
|
|
|
2019-01-20 10:31:24 +00:00
|
|
|
if [ ! -d "$ANDROID_SDK"/build-tools/"${ANDROID_BUILDTOOLS_REVISION}" ] ||
|
|
|
|
[ ! -d "$ANDROID_SDK"/platforms/android-"${ANDROID_PLATFORMS}" ] ||
|
|
|
|
[ ! -d "$ANDROID_SDK"/platforms/android-"${ANDROID_PLATFORM}" ] ; then
|
2018-07-04 05:51:59 +00:00
|
|
|
if [ ! -d "$ANDROID_SDK" ] ; then
|
|
|
|
if [ ! -f "$SDK_TOOLS" ] ; then
|
2018-12-24 19:28:10 +00:00
|
|
|
wget -q https://dl.google.com/android/repository/"$SDK_TOOLS"
|
2018-06-28 10:13:35 +00:00
|
|
|
fi
|
2018-07-04 05:51:59 +00:00
|
|
|
mkdir "$ANDROID_SDK"
|
|
|
|
pushd "$ANDROID_SDK"
|
|
|
|
unzip -q ../"$SDK_TOOLS"
|
2018-06-28 10:13:35 +00:00
|
|
|
yes | tools/bin/sdkmanager --licenses > /dev/null 2>&1 || echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > licenses/android-sdk-license
|
|
|
|
cat licenses/android-sdk-license
|
2019-01-20 10:31:24 +00:00
|
|
|
yes | tools/bin/sdkmanager tools platform-tools 'platforms;'"${ANDROID_PLATFORM}" 'platforms;'"${ANDROID_PLATFORMS}" 'build-tools;'"${ANDROID_BUILDTOOLS_REVISION}" > /dev/null
|
2018-06-28 10:13:35 +00:00
|
|
|
echo ""
|
|
|
|
else
|
2018-07-04 05:51:59 +00:00
|
|
|
pushd "$ANDROID_SDK"
|
2019-01-20 10:31:24 +00:00
|
|
|
yes | tools/bin/sdkmanager tools platform-tools 'platforms;'"${ANDROID_PLATFORM}" 'platforms;'"${ANDROID_PLATFORMS}" 'build-tools;'"${ANDROID_BUILDTOOLS_REVISION}" > /dev/null
|
2017-01-21 05:41:17 +00:00
|
|
|
fi
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2017-12-24 20:58:29 +00:00
|
|
|
# download the Qt installer including Android bits and unpack / install
|
|
|
|
QT_DOWNLOAD_URL=https://download.qt.io/archive/qt/${QT_VERSION}/${LATEST_QT}/${QT_BINARIES}
|
2018-07-04 05:51:59 +00:00
|
|
|
if [ ! -d Qt/"${LATEST_QT}"/android_armv7 ] ; then
|
2018-06-28 10:13:35 +00:00
|
|
|
if [ -d Qt ] ; then
|
|
|
|
# Over writing an exsisting installation stalls the installation script,
|
|
|
|
# rename the exsisting Qt folder and notify then user.
|
|
|
|
mv Qt Qt_OLD
|
|
|
|
echo "Qt installation found, backing it up to Qt_OLD."
|
|
|
|
fi
|
2018-07-04 05:51:59 +00:00
|
|
|
if [ ! -f "${QT_BINARIES}" ] ; then
|
2018-12-24 19:28:10 +00:00
|
|
|
wget -q "${QT_DOWNLOAD_URL}"
|
2017-12-24 20:58:29 +00:00
|
|
|
fi
|
2018-07-04 05:51:59 +00:00
|
|
|
chmod +x ./"${QT_BINARIES}"
|
2018-12-23 23:22:02 +00:00
|
|
|
./"${QT_BINARIES}" --platform minimal --script "$SCRIPTDIR"/qt-installer-noninteractive.qs --no-force-installations
|
2017-12-24 20:58:29 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# patch the cmake / Qt5.7.1 incompatibility mentioned above
|
2018-07-04 05:51:59 +00:00
|
|
|
sed -i 's/set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)/# set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES cxx_decltype)/' Qt/"${LATEST_QT}"/android_armv7/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake
|
2017-12-24 20:58:29 +00:00
|
|
|
|
2018-12-22 17:45:33 +00:00
|
|
|
if [ ! -z ${PREP_ONLY+x} ] ; then
|
2018-12-22 17:13:20 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2017-12-07 04:47:20 +00:00
|
|
|
if [ ! -d subsurface/libdivecomputer/src ] ; then
|
|
|
|
pushd subsurface
|
|
|
|
git submodule init
|
|
|
|
git submodule update --recursive
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2018-12-29 07:40:09 +00:00
|
|
|
# always reconfigure here
|
|
|
|
rm -f subsurface/libdivecomputer/configure
|
|
|
|
pushd subsurface/libdivecomputer
|
|
|
|
autoreconf --install --force
|
|
|
|
autoreconf --install --force
|
|
|
|
popd
|
2017-01-21 05:41:17 +00:00
|
|
|
|
|
|
|
# and now we need a monotonic build number...
|
2017-02-08 17:03:34 +00:00
|
|
|
if [ ! -f ./buildnr.dat ] ; then
|
2017-01-21 05:41:17 +00:00
|
|
|
BUILDNR=0
|
|
|
|
else
|
|
|
|
BUILDNR=$(cat ./buildnr.dat)
|
|
|
|
fi
|
2017-11-15 16:01:11 +00:00
|
|
|
BUILDNR=$((BUILDNR+1))
|
2017-01-21 05:41:17 +00:00
|
|
|
echo "${BUILDNR}" > ./buildnr.dat
|
|
|
|
|
2017-11-15 19:14:09 +00:00
|
|
|
echo "Building Subsurface-mobile for Android, build nr ${BUILDNR}"
|
2017-01-21 05:41:17 +00:00
|
|
|
|
2017-05-27 21:54:28 +00:00
|
|
|
rm -f ./subsurface-mobile-build-arm/build/outputs/apk/*.apk
|
2017-11-15 19:46:39 +00:00
|
|
|
rm -df ./subsurface-mobile-build-arm/AndroidManifest.xml
|
2017-05-27 21:54:28 +00:00
|
|
|
|
2017-02-08 17:03:49 +00:00
|
|
|
if [ "$USE_X" ] ; then
|
2017-11-16 11:35:17 +00:00
|
|
|
bash "$USE_X" "$SUBSURFACE_SOURCE"/packaging/android/build.sh -buildnr "$BUILDNR" arm "$@"
|
2018-12-24 21:31:34 +00:00
|
|
|
bash "$USE_X" "$SUBSURFACE_SOURCE"/packaging/android/build.sh -buildnr "$BUILDNR" arm64 "$@"
|
2017-02-04 15:02:11 +00:00
|
|
|
else
|
2017-11-16 11:35:17 +00:00
|
|
|
bash "$SUBSURFACE_SOURCE"/packaging/android/build.sh -buildnr "$BUILDNR" arm "$@"
|
2018-12-24 21:31:34 +00:00
|
|
|
bash "$SUBSURFACE_SOURCE"/packaging/android/build.sh -buildnr "$BUILDNR" arm64 "$@"
|
2017-02-04 15:02:11 +00:00
|
|
|
fi
|
2017-02-04 01:27:45 +00:00
|
|
|
|
2017-05-27 21:54:28 +00:00
|
|
|
ls -l ./subsurface-mobile-build-arm/build/outputs/apk/*.apk
|
2017-01-21 05:41:17 +00:00
|
|
|
|