File indexing completed on 2024-04-21 03:41:32

0001 #!/bin/sh
0002 # Automate the android builds
0003 # This script creates the aab for Android
0004 #
0005 # SPDX-FileCopyrightText: 2022 Johnny Jazeix <jazeix@gmail.com>
0006 #
0007 #   SPDX-License-Identifier: GPL-3.0-or-later
0008 
0009 Qt5_BaseDIR=~/Qt/5.15.2
0010 export ANDROID_NDK_ROOT=$ANDROID_NDK
0011 
0012 if [ "$#" -eq 1 ]; then
0013     Qt5_BaseDIR=$1
0014     echo "Overriding Qt5_BaseDIR to ${Qt5_BaseDIR}"
0015 fi
0016 
0017 # The current version
0018 version=$(sed -n -e 's/set(GCOMPRIS_MINOR_VERSION \([0-9]\+\)).*/\1/p' CMakeLists.txt)
0019 
0020 # The prefix of the build dir, will be suffixed by the arch target
0021 buildprefix=bb-$version
0022 
0023 #
0024 if [ ! -f org.kde.gcompris.appdata.xml ]
0025 then
0026     echo "ERROR: Run me from the top level GCompris source dir"
0027     exit 1
0028 fi
0029 
0030 # Param: ANDROID_ABI DOWNLOAD KIOSK_MODE
0031 f_cmake()
0032 {
0033     if [ $# != 3 ]
0034     then
0035         echo "f_cmake missing parameter"
0036         return
0037     fi
0038 
0039     if [ -f CMakeCache.txt ]
0040     then
0041         make clean
0042         rm CMakeCache.txt
0043         rm cmake_install.cmake
0044         rm Makefile
0045         rm -rf CMakeFiles
0046     fi
0047 
0048     cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \
0049           -DCMAKE_BUILD_TYPE=Release \
0050           -DCMAKE_FIND_ROOT_PATH=${Qt5_BaseDIR}/${QtTarget}/lib/ \
0051           -DQt5_DIR=${Qt5_BaseDIR}/${QtTarget}/lib/cmake/Qt5 \
0052           -Wno-dev \
0053           -DQML_BOX2D_MODULE=submodule \
0054           -DWITH_DOWNLOAD=$2 \
0055           -DWITH_KIOSK_MODE=$3 \
0056           ${cmake_extra_args} \
0057           ..
0058 
0059 }
0060 
0061 # ARM
0062 QtTarget=android
0063 builddir=${buildprefix}-${QtTarget}
0064 mkdir -p ${builddir}
0065 cd ${builddir}
0066 
0067 # Retrieve the Qt version
0068 if [[ $Qt5_BaseDIR =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
0069     version=${BASH_REMATCH[0]}
0070 fi
0071 n=${version//[!0-9]/ }
0072 a=(${n//\./ })
0073 major=${a[0]}
0074 minor=${a[1]}
0075 patch=${a[2]}
0076 
0077 # If we use Qt > 5.14, we need to update some variables
0078 if [[ $minor -le 14 ]]; then
0079     echo "Using Qt5.14 or less, aborting";
0080     exit 1
0081 fi
0082 cmake_extra_args="-DANDROID_BUILD_ABI_armeabi-v7a=ON -DANDROID_BUILD_ABI_arm64-v8a=ON -DANDROID_BUILD_ABI_x86_64=ON -DANDROID_BUILD_ABI_x86=ON"
0083 QtTarget=android
0084 
0085 f_cmake android ON OFF
0086 make -j 4
0087 make aab_release