ioq3quest/android/run.sh

118 lines
3.4 KiB
Bash
Raw Normal View History

2022-03-14 16:36:35 +00:00
#!/bin/bash
2020-09-06 11:40:32 +00:00
2022-04-03 12:46:35 +00:00
if [ -z "$ANDROID_SDK_ROOT" ]; then
ANDROID_SDK_ROOT=~/Android/Sdk
fi
if [ -z "$ANDROID_TOOLS_VERSION" ]; then
ANDROID_TOOLS_VERSION=29.0.2
fi
if [ -z "$KEYSTORE" ]; then
KEYSTORE=~/.android/release.keystore
fi
2020-09-06 11:40:32 +00:00
2022-04-03 12:46:35 +00:00
SCRIPTDIR=$(readlink -f $(dirname $0))
2022-03-14 16:36:35 +00:00
2022-04-03 12:46:35 +00:00
APP_NAME=$(cat $SCRIPTDIR/app/src/main/res/values/strings.xml | grep "app_name" | cut -d">" -f2 | cut -d"<" -f1 )
APP_VERSION=$(cat $SCRIPTDIR/app/src/main/AndroidManifest.xml | grep "versionName" | cut -d\" -f2 | cut -d\" -f1 )
APP_PACKAGE=$(cat $SCRIPTDIR/app/src/main/AndroidManifest.xml | grep "package" | cut -d\" -f2 | cut -d\" -f1 )
2022-03-14 16:36:35 +00:00
2022-04-03 12:46:35 +00:00
if [ "$1" == "release" ] || [ "$2" == "release" ] || [ "$3" == "release" ] || [ "$4" == "release" ]; then
TARGET=release
GRADLE_BUILD_TYPE=:app:assembleRelease
APK_NAME=app-release-unsigned.apk
else
TARGET=debug
GRADLE_BUILD_TYPE=:app:assembleDebug
APK_NAME=app-debug.apk
2022-03-14 16:36:35 +00:00
fi
2022-04-03 12:46:35 +00:00
APK_LOCATION="$SCRIPTDIR/app/build/outputs/apk/$TARGET"
if [ "$1" == "clean" ] || [ "$2" == "clean" ] || [ "$3" == "clean" ] || [ "$4" == "clean" ]; then
rm -rf $SCRIPTDIR/../build
rm -rf $SCRIPTDIR/build
rm -rf $SCRIPTDIR/app/build
rm -rf $SCRIPTDIR/app/src/main/jniLibs
fi
2022-03-14 16:36:35 +00:00
2022-04-03 12:46:35 +00:00
cd $SCRIPTDIR/app/src/main/pakQ3Q
rm -f $SCRIPTDIR/app/src/main/assets/pakQ3Q.pk3
zip -r $SCRIPTDIR/app/src/main/assets/pakQ3Q.pk3 .
echo "#define Q3QVERSION \"$APP_VERSION"\" > $SCRIPTDIR/app/src/main/cpp/code/vr/vr_version.h
cd $SCRIPTDIR/..
2022-03-14 16:36:35 +00:00
make -j $(getconf _NPROCESSORS_ONLN) $TARGET
2020-09-06 11:40:32 +00:00
if [ $? -ne 0 ]; then
echo "Failed to build ioq3"
exit 1
fi
2022-04-03 12:46:35 +00:00
cd $SCRIPTDIR
2020-09-06 11:40:32 +00:00
2022-04-03 12:46:35 +00:00
./gradlew "$GRADLE_BUILD_TYPE"
2020-09-06 11:40:32 +00:00
if [ $? -ne 0 ]; then
echo "Failed to build android project"
exit 1
fi
2022-04-03 12:46:35 +00:00
UNSIGNED_APK="$APK_LOCATION/$APK_NAME"
if [ "$TARGET" == "release" ]; then
echo "Signing Release APK"
APK_NAME="$APP_NAME-release-$APP_VERSION.apk"
SIGNED_APK="$APK_LOCATION/$APK_NAME"
if [ -z "$KEYSTORE_PASS" ]; then
echo ""
echo "Keystore Password:"
read -s KEYSTORE_PASS
fi
apksigner="$ANDROID_SDK_ROOT/build-tools/$ANDROID_TOOLS_VERSION/apksigner"
$apksigner sign --ks "$KEYSTORE" --out "$SIGNED_APK" --v2-signing-enabled true --ks-pass "pass:$KEYSTORE_PASS" "$UNSIGNED_APK"
rm "$UNSIGNED_APK"
else
APK_NAME="$APP_NAME-debug-$APP_VERSION.apk"
mv "$UNSIGNED_APK" "$APK_LOCATION/$APK_NAME"
fi
2020-09-06 11:40:32 +00:00
2022-04-03 12:46:35 +00:00
if [ "$1" == "install" ] || [ "$2" == "install" ] || [ "$3" == "install" ] || [ "$4" == "install" ]; then
adb install -r "$APK_LOCATION/$APK_NAME"
2022-03-14 16:36:35 +00:00
if [ $? -ne 0 ]; then
2022-04-03 12:46:35 +00:00
adb uninstall $APP_PACKAGE
adb install "$APK_LOCATION/$APK_NAME"
2022-03-14 16:36:35 +00:00
if [ $? -ne 0 ]; then
echo "Failed to install apk."
exit 1
fi
fi
2020-09-06 11:40:32 +00:00
fi
2022-03-14 16:36:35 +00:00
2022-04-03 12:46:35 +00:00
#ANDROID_STORAGE_LOCATION=/sdcard/Android/data/$APP_PACKAGE/files/
2022-03-04 15:23:57 +00:00
#adb shell mkdir -p $ANDROID_STORAGE_LOCATION
#adb push --sync ~/.local/share/Steam/steamapps/common/Quake\ 3\ Arena/baseq3 $ANDROID_STORAGE_LOCATION
#if [ $? -ne 0 ]; then
# echo "Failed to transfer files."
# exit 1
#fi
#adb push --sync ../code/renderergl2/glsl $ANDROID_STORAGE_LOCATION/baseq3/
#if [ $? -ne 0 ]; then
# echo "Failed to transfer shaders."
# exit 1
#fi
#adb push --sync autoexec.cfg $ANDROID_STORAGE_LOCATION/baseq3/
#if [ $? -ne 0 ]; then
# echo "Failed to transfer autoexec."
# exit 1
#fi
2020-09-06 11:40:32 +00:00
2022-04-03 12:46:35 +00:00
if [ "$1" == "start" ] || [ "$2" == "start" ] || [ "$3" == "start" ] || [ "$4" == "start" ]; then
2022-03-14 16:36:35 +00:00
adb logcat -c
2022-04-03 12:46:35 +00:00
adb shell am start -n $APP_PACKAGE/.MainActivity
2022-03-14 16:36:35 +00:00
if [ $? -ne 0 ]; then
echo "Failed to start application."
exit 1
fi
adb logcat *:S Quake3:V SDL:V DEBUG:V
2020-09-06 11:40:32 +00:00
fi