File indexing completed on 2023-05-30 10:41:17

0001 #!/bin/bash
0002 # Automate the android builds
0003 # This script creates the different apk for arm and x86
0004 #
0005 # SPDX-FileCopyrightText: 2016 Bruno Coudoin <bruno.coudoin@gcompris.net>
0006 #
0007 #   SPDX-License-Identifier: GPL-3.0-or-later
0008 
0009 # =======================================================================
0010 # This script builds an 'embedded' apk that includes a list of resources.
0011 # =======================================================================
0012 
0013 #
0014 # Uncomment if this is not already done
0015 # make getSvnTranslations
0016 
0017 Qt5_BaseDIR=~/Qt/5.12.6
0018 export ANDROID_NDK_ROOT=$ANDROID_NDK
0019 
0020 # The current version
0021 version=$(sed -n -e 's/set(GCOMPRIS_MINOR_VERSION \([0-9]\+\)).*/\1/p' CMakeLists.txt)
0022 
0023 # The prefix of the build dir, will be suffixed by the arch target
0024 buildprefix=emb-$version
0025 
0026 #
0027 if [ ! -f org.kde.gcompris.appdata.xml ]
0028 then
0029     echo "ERROR: Run me from the top level GCompris source dir"
0030     exit 1
0031 fi
0032 
0033 if [ "$#" == "0" ]
0034 then
0035     echo "ERROR: Missing download asset parameter (e.g: words,en,fr)"
0036     exit 1
0037 fi
0038 download_assets=$1
0039 
0040 # Param: ANDROID_ABI DOWNLOAD KIOSK_MODE DOWNLOAD_ASSETS
0041 # DOWNLOAD_ASSETS: list of assets to bundle in the apk
0042 #  e.g: words,en,fr,music # This packages the large words rcc, the french and english voices, and the music
0043 f_cmake()
0044 {
0045     if [ $# != 4 ]
0046     then
0047         echo "f_cmake parameter number mismatch"
0048         return
0049     fi
0050 
0051     if [ -f CMakeCache.txt ]
0052     then
0053         make clean
0054         rm CMakeCache.txt
0055         rm cmake_install.cmake
0056         rm Makefile
0057         rm -rf CMakeFiles
0058     fi
0059 
0060     cmake -DCMAKE_TOOLCHAIN_FILE=~/ecm/share/ECM/toolchain/Android.cmake \
0061           -DCMAKE_BUILD_TYPE=Release \
0062           -DANDROID_ABI=$1 \
0063           -DCMAKE_FIND_ROOT_PATH=${Qt5_BaseDIR}/${QtTarget}/lib/ \
0064           -DQt5_DIR=${Qt5_BaseDIR}/${QtTarget}/lib/cmake/Qt5 \
0065           -Wno-dev \
0066           -DQML_BOX2D_MODULE=submodule \
0067           -DWITH_DOWNLOAD=$2 \
0068           -DWITH_KIOSK_MODE=$3 \
0069           -DDOWNLOAD_ASSETS=$4 \
0070           ..
0071 
0072 }
0073 
0074 # ARM
0075 QtTarget=android_armv7
0076 builddir=${buildprefix}-${QtTarget}
0077 mkdir -p ${builddir}
0078 cd ${builddir}
0079 
0080 
0081 f_cmake armeabi-v7a OFF OFF $download_assets
0082 make
0083 make BuildTranslations
0084 make getAssets
0085 make apk_aligned_signed
0086 
0087 # Remove extra apk
0088 rm -f android/*release-arm*
0089 rm -f android/*release-signed-arm*