diff --git a/android/Android.mk b/android/Android.mk index 947ca5490..37b5d33da 100644 --- a/android/Android.mk +++ b/android/Android.mk @@ -162,8 +162,9 @@ LOCAL_CFLAGS := -I../lib/angelscript/include \ -DUSE_GLES2 \ -DHAVE_OGGVORBIS \ -DNDEBUG \ - -DANDROID_PACKAGE_NAME=\"$(PACKAGE_NAME)\" \ - -DANDROID_APP_DIR_NAME=\"$(APP_DIR_NAME)\" \ + -DANDROID_PACKAGE_NAME=\"$(PACKAGE_NAME)\" \ + -DANDROID_APP_DIR_NAME=\"$(APP_DIR_NAME)\" \ + -DSUPERTUXKART_VERSION=\"$(PROJECT_VERSION)\" \ -std=gnu++0x LOCAL_STATIC_LIBRARIES := irrlicht bullet enet freetype ifaddrs angelscript \ diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index caa4cfc18..3a3af85ee 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,7 +2,7 @@ diff --git a/android/README.ANDROID b/android/README.ANDROID index 3577506b8..334ce4a38 100644 --- a/android/README.ANDROID +++ b/android/README.ANDROID @@ -101,6 +101,14 @@ SDK_PATH - Path to SDK directory NDK_PATH - Path to NDK directory +PROJECT_VERSION - Set Supertuxkart version number, for example "0.9.3" or + "git20170409" or whatever. + Default is: git. + +PROJECT_CODE - Set Supertuxkart version code that is used in the manifest + file. + Default is: 1. + -------------------------------------------------------------------------------- @@ -110,29 +118,13 @@ NDK_PATH - Path to NDK directory Making a release build is similar to typical compilation, but there are few additional things to do. -You have to change version numbers. This is important, because assets manager -in STK checks these numbers and detects if already extracted data files are +You have to set PROJECT_VERSION variable. This is important, because assets +manager in STK checks that value and detects if already extracted data files are up to date. So that when you will install new STK version, this will force new data extraction automatically. -So that you have to: - -1. Change "data/supertuxkart.git" to "data/supertuxkart.VERSION_NUMBER" - -2. Open "src/utils/constants.cpp" and change: - - const char STK_VERSION[] = "git"; - - to - - const char STK_VERSION[] = "VERSION_NUMBER"; - - where "VERSION_NUMBER" is for example "0.9.3" or "git20170409" or whatever. - -3. You can also update these lines in "android/AndroidManifest.xml": - android:versionCode="1" - android:versionName="1.0" - +The PROJECT_CODE variable typically should be set to a value higher than for +previous release, so that users will receive the upgrade. Before compilation you have to set: diff --git a/android/make.sh b/android/make.sh index cb9dc540e..8dbac3e11 100755 --- a/android/make.sh +++ b/android/make.sh @@ -232,6 +232,51 @@ if [ -z "$BUILD_TOOLS_VER" ] || [ ! -d "$SDK_PATH/build-tools/$BUILD_TOOLS_VER" exit fi +# Set project version and code +if [ -f "$DIRNAME/obj/project_version" ]; then + PROJECT_VERSION_PREV=$(cat "$DIRNAME/obj/project_version") + + if [ -z "$PROJECT_VERSION" ]; then + PROJECT_VERSION="$PROJECT_VERSION_PREV" + elif [ "$PROJECT_VERSION" != "$PROJECT_VERSION_PREV" ]; then + echo "Error: Compilation of different version has been already made." + echo "Run './make.sh clean' first or set PROJECT_VERSION variable" \ + "to '$PROJECT_VERSION_PREV.'" + exit + fi +fi + +if [ -z "$PROJECT_VERSION" ]; then + if [ $IS_DEBUG_BUILD -ne 0 ]; then + PROJECT_VERSION="git" + else + echo "Error: Variable PROJECT_VERSION is not set. It must have unique" \ + "value for release build." + exit + fi +fi + +if [ -z "$PROJECT_CODE" ]; then + if [ $IS_DEBUG_BUILD -ne 0 ]; then + PROJECT_CODE="1" + else + echo "Error: Variable PROJECT_CODE is not set." + exit + fi +fi + +if [ -d "$DIRNAME/assets/data" ]; then + if [ ! -f "$DIRNAME/assets/data/supertuxkart.$PROJECT_VERSION" ]; then + echo "Error: supertuxkart.$PROJECT_VERSION doesn't exist in" \ + "assets/data directory." + exit + fi +fi + +if [ ! -f "$DIRNAME/obj/project_version" ]; then + echo "$PROJECT_VERSION" > "$DIRNAME/obj/project_version" +fi + # Standalone toolchain if [ ! -f "$DIRNAME/obj/make_standalone_toolchain.stamp" ]; then @@ -425,6 +470,12 @@ sed -i "s/targetSdkVersion=\".*\"/targetSdkVersion=\"$TARGET_SDK_VERSION\"/g" \ sed -i "s/package=\".*\"/package=\"$PACKAGE_NAME\"/g" \ "$DIRNAME/AndroidManifest.xml" +sed -i "s/versionName=\".*\"/versionName=\"$PROJECT_VERSION\"/g" \ + "$DIRNAME/AndroidManifest.xml" + +sed -i "s/versionCode=\".*\"/versionCode=\"$PROJECT_CODE\"/g" \ + "$DIRNAME/AndroidManifest.xml" + cp "banner.png" "$DIRNAME/res/drawable/banner.png" cp "$APP_ICON" "$DIRNAME/res/drawable/icon.png" convert -scale 72x72 "$APP_ICON" "$DIRNAME/res/drawable-hdpi/icon.png"