#!/bin/bash
<<COMMENT
ROOT_DIR=`dirname "$0"`
if [ "$ARCH" == "arm" ]
then
mkdir -p $ROOT_DIR/android-build-arm
cd $ROOT_DIR/android-build-arm
export ANDROID_ARCH=arm
export ANDROID_ARCH_ABI=armeabi-v7a
cmake -DCMAKE_INSTALL_PREFIX=/home/user/build-arm -DCMAKE_PREFIX_PATH="$QT_PATH;/opt/kdeandroid-arm/" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/opt/nativetooling/share/ECM/toolchain/Android.cmake -DQTANDROID_EXPORTED_TARGET=vehiclevoyage -DCMAKE_ANDROID_API=android-28 -DANDROID_API_LEVEL=28 -DANDROID_APK_DIR=../packaging/android -DKF5_HOST_TOOLING=/opt/nativetooling/lib/x86_64-linux-gnu/cmake/ ..
make install
make create-apk
fi
if [ "$ARCH" == "arm64" ]
then
mkdir -p $ROOT_DIR/android-build-aarch64
cd $ROOT_DIR/android-build-aarch64
export ANDROID_ARCH=arm64
export ANDROID_ARCH_ABI=arm64-v8a
cmake -DCMAKE_INSTALL_PREFIX=/home/user/build-arm64 -DCMAKE_PREFIX_PATH="$QT_PATH;/opt/kdeandroid-arm64/" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/opt/nativetooling/share/ECM/toolchain/Android.cmake -DQTANDROID_EXPORTED_TARGET=vehiclevoyage -DCMAKE_ANDROID_API=android-28 -DANDROID_API_LEVEL=28 -DANDROID_APK_DIR=../packaging/android -DKF5_HOST_TOOLING=/opt/nativetooling/lib/x86_64-linux-gnu/cmake/ ..
make install
make create-apk
fi
if [ -z $ARCH ]
then
echo "Need ARCH set to arm or arm64 build."
fi
COMMENT
ROOT_DIR=$(dirname $(realpath -s $0))
mkdir -p $ROOT_DIR/builds
docker run --rm -it -v $ROOT_DIR:/home/user/src/vv kdeorg/android-sdk bash -c "git clone --depth 1 kde:sysadmin/ci-tooling;/opt/helpers/build-kde-project kirigami Frameworks -DBUILD_TESTING=OFF; /opt/helpers/build-kde-project kcoreaddons Frameworks -DBUILD_TESTING=OFF;/opt/helpers/build-cmake vv vv -DQTANDROID_EXPORTED_TARGET=vehiclevoyage -DANDROID_APK_DIR=/home/user/src/vv/packaging/android -DANDROID_APK_OUTPUT_DIR=/home/user/src/vv/builds;make -C /home/user/build-arm/vv create-apk;make -C /home/user/build-arm64/vv create-apk"
