2018-10-04 14:46:30 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# (C) 2018 Dawid Gan, under the GPLv3
|
|
|
|
#
|
|
|
|
# A script that builds Android APKs for all architectures
|
|
|
|
#
|
|
|
|
# The script assumes that you know what you are doing. It allows to generate all
|
|
|
|
# packages for Google Play Store with single command. If you just want to build
|
|
|
|
# STK for your own use, then use android/make.sh script instead.
|
|
|
|
|
|
|
|
export BUILD_TYPE=Beta
|
2021-10-04 22:00:38 -04:00
|
|
|
export PROJECT_VERSION=git20211004
|
|
|
|
export PROJECT_CODE=299
|
2020-08-27 04:28:13 -04:00
|
|
|
export STK_STOREPASS="xxx"
|
|
|
|
export STK_KEYSTORE="/path/to/stk.keystore"
|
|
|
|
export STK_ALIAS="alias"
|
2018-10-04 14:46:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
check_error()
|
|
|
|
{
|
|
|
|
if [ $? -gt 0 ]; then
|
|
|
|
echo "Error ocurred."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
clean()
|
|
|
|
{
|
|
|
|
echo "Clean everything"
|
|
|
|
|
|
|
|
rm -rf ./android/assets
|
|
|
|
rm -rf ./android-output
|
|
|
|
|
|
|
|
cd android
|
|
|
|
./make.sh clean
|
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
|
|
|
generate_assets()
|
|
|
|
{
|
|
|
|
echo "Generate assets"
|
|
|
|
|
|
|
|
if [ -d "./android/assets" ]; then
|
|
|
|
echo "Assets already found in ./android/assets"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd ./android
|
2020-02-22 18:40:04 -05:00
|
|
|
DECREASE_QUALITY=0 \
|
|
|
|
CONVERT_TO_JPG=0 \
|
|
|
|
ASSETS_PATHS="../android-output/assets-lq/data" \
|
2018-10-04 14:46:30 -04:00
|
|
|
./generate_assets.sh
|
|
|
|
|
2020-08-27 04:28:13 -04:00
|
|
|
if [ ! -f "./assets/files.txt" ]; then
|
2018-10-04 14:46:30 -04:00
|
|
|
echo "Error: Couldn't generate assets"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "./assets/data/supertuxkart.git" ]; then
|
|
|
|
mv "./assets/data/supertuxkart.git" \
|
|
|
|
"./assets/data/supertuxkart.$PROJECT_VERSION"
|
2020-08-27 04:28:13 -04:00
|
|
|
sed -i "s/data\/supertuxkart.git/data\/supertuxkart.$PROJECT_VERSION/g" \
|
|
|
|
"./assets/files.txt"
|
2018-10-04 14:46:30 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd -
|
|
|
|
}
|
|
|
|
|
2019-10-14 19:04:24 -04:00
|
|
|
generate_full_assets()
|
|
|
|
{
|
|
|
|
echo "Generate zip file with full assets"
|
|
|
|
|
|
|
|
if [ -f "./android-output/stk-assets.zip" ]; then
|
|
|
|
echo "Full assets already found in ./android-output/stk-assets.zip"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -a ./android/generate_assets.sh ./android-output/
|
|
|
|
|
|
|
|
cd ./android-output/
|
|
|
|
|
2020-02-22 18:40:04 -05:00
|
|
|
ONLY_ASSETS=1 \
|
|
|
|
TRACKS="all" \
|
|
|
|
TEXTURE_SIZE=512 \
|
|
|
|
JPEG_QUALITY=95 \
|
|
|
|
PNG_QUALITY=95 \
|
|
|
|
PNGQUANT_QUALITY=95 \
|
|
|
|
SOUND_QUALITY=112 \
|
|
|
|
SOUND_MONO=0 \
|
|
|
|
SOUND_SAMPLE=44100 \
|
|
|
|
OUTPUT_PATH="assets-hq" \
|
2019-10-14 19:04:24 -04:00
|
|
|
./generate_assets.sh
|
|
|
|
|
2020-08-27 04:28:13 -04:00
|
|
|
if [ ! -f "./assets-hq/files.txt" ]; then
|
2019-10-18 11:57:50 -04:00
|
|
|
echo "Error: Couldn't generate full assets"
|
2019-10-14 19:04:24 -04:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2020-02-22 18:40:04 -05:00
|
|
|
cd ./assets-hq/data
|
2019-10-14 19:04:24 -04:00
|
|
|
zip -r ../../stk-assets.zip ./*
|
|
|
|
cd ../../
|
|
|
|
|
|
|
|
rm ./generate_assets.sh
|
2019-10-18 11:57:50 -04:00
|
|
|
|
|
|
|
if [ ! -f "./stk-assets.zip" ]; then
|
|
|
|
echo "Error: Couldn't generate full assets"
|
|
|
|
return
|
|
|
|
fi
|
2019-10-14 19:04:24 -04:00
|
|
|
|
2019-10-18 11:57:50 -04:00
|
|
|
FULL_ASSETS_SIZE=`du -b ./stk-assets.zip | cut -f1`
|
|
|
|
sed -i "s/stk_assets_size = .*\;/stk_assets_size = $FULL_ASSETS_SIZE\;/g" \
|
|
|
|
"../src/utils/download_assets_size.hpp"
|
|
|
|
|
2019-10-14 19:04:24 -04:00
|
|
|
cd ../
|
|
|
|
}
|
|
|
|
|
2020-02-22 18:40:04 -05:00
|
|
|
generate_lq_assets()
|
|
|
|
{
|
|
|
|
echo "Generate zip file with lq assets"
|
|
|
|
|
|
|
|
if [ -f "./android-output/stk-assets-lq.zip" ]; then
|
|
|
|
echo "Full assets already found in ./android-output/stk-assets-lq..zip"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -a ./android/generate_assets.sh ./android-output/
|
|
|
|
|
|
|
|
cd ./android-output/
|
|
|
|
|
|
|
|
ONLY_ASSETS=1 \
|
|
|
|
OUTPUT_PATH="assets-lq" \
|
|
|
|
./generate_assets.sh
|
|
|
|
|
2020-08-27 04:28:13 -04:00
|
|
|
if [ ! -f "./assets-lq/files.txt" ]; then
|
2020-02-22 18:40:04 -05:00
|
|
|
echo "Error: Couldn't generate lq assets"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd ./assets-lq/data
|
|
|
|
zip -r ../../stk-assets-lq.zip ./*
|
|
|
|
cd ../../
|
|
|
|
|
|
|
|
rm ./generate_assets.sh
|
|
|
|
|
|
|
|
if [ ! -f "./stk-assets-lq.zip" ]; then
|
|
|
|
echo "Error: Couldn't generate lq assets"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd ../
|
|
|
|
}
|
|
|
|
|
2018-10-04 14:46:30 -04:00
|
|
|
# Handle clean command
|
|
|
|
if [ ! -z "$1" ] && [ "$1" = "clean" ]; then
|
|
|
|
clean
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
#Build packages
|
|
|
|
|
2020-02-22 18:40:04 -05:00
|
|
|
generate_lq_assets
|
2019-10-18 11:57:50 -04:00
|
|
|
generate_full_assets
|
2020-02-22 18:40:04 -05:00
|
|
|
generate_assets
|
2018-10-04 14:46:30 -04:00
|
|
|
|
2021-09-25 04:20:09 -04:00
|
|
|
if [ -f "./android-output/SuperTuxKart-$PROJECT_VERSION.apk" ]; then
|
|
|
|
echo "Package for architecture $ARCH1 is already built"
|
|
|
|
#exit
|
2018-10-04 14:46:30 -04:00
|
|
|
fi
|
|
|
|
|
2021-09-25 04:20:09 -04:00
|
|
|
cd ./android
|
|
|
|
./make_deps.sh
|
2021-10-04 22:00:38 -04:00
|
|
|
check_error
|
2021-09-25 04:20:09 -04:00
|
|
|
./make.sh
|
|
|
|
cd -
|
2018-10-04 14:46:30 -04:00
|
|
|
|
2021-09-25 04:20:09 -04:00
|
|
|
if [ ! -f ./android/build/outputs/apk/release/android-release.apk ]; then
|
|
|
|
echo "Error: Couldn't build apk"
|
|
|
|
exit
|
2018-10-04 14:46:30 -04:00
|
|
|
fi
|
|
|
|
|
2021-09-25 04:20:09 -04:00
|
|
|
if [ ! -f ./android/build/outputs/bundle/release/android-release.aab ]; then
|
|
|
|
echo "Error: Couldn't build app bundle"
|
|
|
|
exit
|
2018-10-04 14:46:30 -04:00
|
|
|
fi
|
|
|
|
|
2021-09-25 04:20:09 -04:00
|
|
|
cp ./android/build/outputs/apk/release/android-release.apk \
|
|
|
|
./android-output/SuperTuxKart-$PROJECT_VERSION.apk
|
2018-10-04 14:46:30 -04:00
|
|
|
|
2021-09-25 04:20:09 -04:00
|
|
|
cp ./android/build/outputs/bundle/release/android-release.aab \
|
|
|
|
./android-output/SuperTuxKart-$PROJECT_VERSION.aab
|