File indexing completed on 2024-09-29 03:26: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 Qt5_BaseDIR=~/Qt/5.12.12 0014 export ANDROID_NDK_ROOT=$ANDROID_NDK 0015 0016 # The current version 0017 version=$(sed -n -e 's/set(GCOMPRIS_MINOR_VERSION \([0-9]\+\)).*/\1/p' CMakeLists.txt) 0018 0019 # The prefix of the build dir, will be suffixed by the arch target 0020 buildprefix=emb-$version 0021 0022 # 0023 if [ ! -f org.kde.gcompris.appdata.xml ] 0024 then 0025 echo "ERROR: Run me from the top level GCompris source dir" 0026 exit 1 0027 fi 0028 0029 if [ "$#" == "0" ] 0030 then 0031 echo "ERROR: Missing download asset parameter (e.g: words,en,fr)" 0032 exit 1 0033 fi 0034 download_assets=$1 0035 0036 # Param: ANDROID_ABI DOWNLOAD KIOSK_MODE DOWNLOAD_ASSETS 0037 # DOWNLOAD_ASSETS: list of assets to bundle in the apk 0038 # e.g: words,en,fr,music # This packages the large words rcc, the french and english voices, and the music 0039 f_cmake() 0040 { 0041 if [ $# != 4 ] 0042 then 0043 echo "f_cmake parameter number mismatch" 0044 return 0045 fi 0046 0047 if [ -f CMakeCache.txt ] 0048 then 0049 make clean 0050 rm CMakeCache.txt 0051 rm cmake_install.cmake 0052 rm Makefile 0053 rm -rf CMakeFiles 0054 fi 0055 0056 cmake -DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \ 0057 -DCMAKE_ANDROID_API=16 \ 0058 -DCMAKE_BUILD_TYPE=Release \ 0059 -DANDROID_ABI=$1 \ 0060 -DCMAKE_FIND_ROOT_PATH=${Qt5_BaseDIR}/${QtTarget}/lib/ \ 0061 -DQt5_DIR=${Qt5_BaseDIR}/${QtTarget}/lib/cmake/Qt5 \ 0062 -Wno-dev \ 0063 -DQML_BOX2D_MODULE=submodule \ 0064 -DWITH_DOWNLOAD=$2 \ 0065 -DWITH_KIOSK_MODE=$3 \ 0066 -DDOWNLOAD_ASSETS=$4 \ 0067 ${cmake_extra_args} \ 0068 .. 0069 0070 } 0071 0072 # ARM 0073 QtTarget=android_armv7 0074 builddir=${buildprefix}-${QtTarget} 0075 mkdir -p ${builddir} 0076 cd ${builddir} 0077 0078 # Retrieve the Qt version 0079 if [[ $Qt5_BaseDIR =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then 0080 version=${BASH_REMATCH[0]} 0081 fi 0082 n=${version//[!0-9]/ } 0083 a=(${n//\./ }) 0084 major=${a[0]} 0085 minor=${a[1]} 0086 patch=${a[2]} 0087 0088 # If we use Qt > 5.14, we need to update some variables 0089 if [[ $minor -ge 14 ]]; then 0090 echo "Using Qt5.14 or more"; 0091 cmake_extra_args="-DANDROID_BUILD_ABI_armeabi-v7a=ON" 0092 QtTarget=android 0093 fi 0094 0095 f_cmake armeabi-v7a OFF OFF $download_assets 0096 make -j 4 0097 make getAssets 0098 make apk_aligned_signed 0099 0100 # Remove extra apk 0101 rm -f android-build/*release-armeabi* 0102 rm -f android-build/*release-signed-armeabi*