From e4a7fd59f751fe8ebb5d40f75b4f12bae5807744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Thu, 9 May 2024 12:19:47 +0200 Subject: [PATCH] Determine default version name and code from `version.h` Parse `GAME_RELEASE_VERSION` and `DDNET_VERSION_NUMBER` definitions from `src/game/version.h` by default, so specifying a version manually is usually not necessary. --- scripts/android/cmake_android.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/android/cmake_android.sh b/scripts/android/cmake_android.sh index d7aeca8b6..116adba2d 100755 --- a/scripts/android/cmake_android.sh +++ b/scripts/android/cmake_android.sh @@ -84,7 +84,11 @@ export TW_KEY_ALIAS=$_ANDROID_JAR_KEY_ALIAS _ANDROID_VERSION_CODE=1 if [ -z ${TW_VERSION_CODE+x} ]; then - printf "\e[31m%s\e[30m\n" "Did not pass a version code, using default: ${_ANDROID_VERSION_CODE}" + _ANDROID_VERSION_CODE=$(grep '#define DDNET_VERSION_NUMBER' src/game/version.h | awk '{print $3}') + if [ -z ${_ANDROID_VERSION_CODE+x} ]; then + _ANDROID_VERSION_CODE=1 + fi + printf "\e[31m%s\e[30m\n" "Did not pass a version code, using default: ${_ANDROID_VERSION_CODE}" else _ANDROID_VERSION_CODE=$TW_VERSION_CODE fi @@ -93,7 +97,11 @@ export TW_VERSION_CODE=$_ANDROID_VERSION_CODE _ANDROID_VERSION_NAME="1.0" if [ -z ${TW_VERSION_NAME+x} ]; then - printf "\e[31m%s\e[30m\n" "Did not pass a version name, using default: ${_ANDROID_VERSION_NAME}" + _ANDROID_VERSION_NAME="$(grep '#define GAME_RELEASE_VERSION' src/game/version.h | awk '{print $3}' | tr -d '"')" + if [ -z ${_ANDROID_VERSION_NAME+x} ]; then + _ANDROID_VERSION_NAME="1.0" + fi + printf "\e[31m%s\e[30m\n" "Did not pass a version name, using default: ${_ANDROID_VERSION_NAME}" else _ANDROID_VERSION_NAME=$TW_VERSION_NAME fi