diff --git a/xwords4/android/app/build.gradle b/xwords4/android/app/build.gradle index ea492471a..b52b125ea 100644 --- a/xwords4/android/app/build.gradle +++ b/xwords4/android/app/build.gradle @@ -5,6 +5,7 @@ def VERSION_CODE_BASE = 111 def VERSION_NAME = '4.4.115' def VARIANTS = [ "xw4", "xw4dbg" ] def BUILDS = [ "Debug", "Release" ] +def GITREV = "git describe --tags --dirty".execute().text.trim() apply plugin: 'com.android.application' @@ -26,9 +27,8 @@ android { def CRITTERCISM_APP_ID = System.getenv("CRITTERCISM_APP_ID") variant.buildConfigField "String", "CRITTERCISM_APP_ID", "\"$CRITTERCISM_APP_ID\"" - def gitHash = "../scripts/gitversion.sh".execute().text.trim() - resValue "string", "git_rev", "$gitHash" - variant.buildConfigField "String", "GIT_REV", "\"$gitHash\"" + resValue "string", "git_rev", "$GITREV" + variant.buildConfigField "String", "GIT_REV", "\"$GITREV\"" // def stamp = Long.valueOf('date +\'%s\''.execute().text.trim()); def stamp = Math.round(System.currentTimeMillis() / 1000) @@ -148,11 +148,10 @@ android { abortOnError false } - def gitrev = "git describe --tags --dirty".execute().text.trim() applicationVariants.all { variant -> variant.outputs.each { output -> def newName = output.outputFile.name - newName = newName.replace(".apk","-${gitrev}.apk") + newName = newName.replace(".apk","-${GITREV}.apk") newName = newName.replace("app-","") output.outputFile = new File(output.outputFile.parent, newName) } diff --git a/xwords4/android/scripts/genvers.sh b/xwords4/android/scripts/genvers.sh deleted file mode 100755 index 99b2c40ad..000000000 --- a/xwords4/android/scripts/genvers.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh - -set -e -u - -STRINGS_HASH="" -OUT_PATH="" -VARIANT="" -CLIENT_VERS_RELAY="" -GCM_SENDER_ID=${GCM_SENDER_ID:-""} -CRITTERCISM_APP_ID=${CRITTERCISM_APP_ID:-""} -WIDIR_ENABLED=false - -usage() { - echo "usage: $0 --variant --client-vers \\" - echo " [--vers-outfile path/to/versout.txt]" - echo " [--widir-enabled true|false]" - - exit 1 -} - -while [ $# -gt 0 ]; do - echo $1 - case $1 in - --variant) - VARIANT=$2 - shift - ;; - --client-vers) - CLIENT_VERS_RELAY=$2 - shift - ;; - --vers-outfile) - OUT_PATH=$2 - shift - ;; - --widir-enabled) - WIDIR_ENABLED=$2 - shift - ;; - *) - usage - ;; - esac - shift -done - -[ -n "$VARIANT" -a -n "$CLIENT_VERS_RELAY" ] || usage - -BUILD_DIR=$(basename $(pwd)) -cd $(dirname $0) -cd ../ - -GITVERSION=$(../scripts/gitversion.sh) -if [ -n "$OUT_PATH" ]; then - echo $GITVERSION > $BUILD_DIR/$OUT_PATH - git describe >> $BUILD_DIR/$OUT_PATH -fi - -case $VARIANT in - xw4) - APPNAME=Crosswords - SMSPORT=3344 - INVITE_PREFIX=/and/ - DBG_TAG=XW4 - ;; - xw4dbg) - APPNAME=CrossDbg - SMSPORT=3345 - INVITE_PREFIX=/anddbg/ - DBG_TAG=X4BG - ;; - *) - usage - ;; -esac - - -# Need to verify that R.java is unmodified; otherwise we can't set -# this constant!!! Shouldn't be a problem with release builds, -# though. -if ! git status | grep -q "modified:.*${BUILD_DIR}/archive/R.java"; then - STRINGS_HASH=$(git log -- ${BUILD_DIR}/archive/R.java | grep '^commit ' | head -n 1 | awk '{print $2}') -fi -# TODO: deal with case where there's no hash available -- exported -# code maybe? Better: gitversion.sh does that. - -cat < ${BUILD_DIR}/res/values/gen_strings.xml - - - - - $APPNAME - $GITVERSION - $SMSPORT - $INVITE_PREFIX - -EOF - -# Eventually this should pick up a tag if we're at one. That'll be -# the way to mark a release -SHORTVERS="$(git describe --always $GITVERSION 2>/dev/null || echo ${GITVERSION}+)" -GITHASH=$(git rev-parse --verify HEAD) - -if [ -z "$GCM_SENDER_ID" ]; then - echo "GCM_SENDER_ID empty; GCM use will be disabled" >&2 -fi -if [ -z "$CRITTERCISM_APP_ID" ]; then - echo "CRITTERCISM_APP_ID empty; Crittercism will not be enabled" >&2 -fi - -cat < ${BUILD_DIR}/src/org/eehouse/android/${VARIANT}/BuildConstants.java -// auto-generated (by $(basename $0)); do not edit -package org.eehouse.android.${VARIANT}; -public class BuildConstants { - public static final String GIT_REV = "$SHORTVERS"; - public static final String STRINGS_HASH = "$STRINGS_HASH"; - public static final short CLIENT_VERS_RELAY = $CLIENT_VERS_RELAY; - public static final long BUILD_STAMP = $(date +'%s'); - public static final String DBG_TAG = "$DBG_TAG"; - public static final String VARIANT = "$VARIANT"; - public static final String GCM_SENDER_ID = "${GCM_SENDER_ID}"; - public static final String CRITTERCISM_APP_ID = "${CRITTERCISM_APP_ID}"; - public static final boolean WIDIR_ENABLED = ${WIDIR_ENABLED}; -} -EOF - -# touch the files that depend on git_string.xml. (I'm not sure that -# this list is complete or if ant and java always get dependencies -# right. Clean builds are the safest.) -touch ${BUILD_DIR}/res/xml/xwprefs.xml -echo "touched ${BUILD_DIR}/res/xml/xwprefs.xml" -mkdir -p ${BUILD_DIR}/gen/org/eehouse/android/${VARIANT} -touch ${BUILD_DIR}/gen/org/eehouse/android/${VARIANT}/R.java -touch ${BUILD_DIR}/src/org/eehouse/android/${VARIANT}/Utils.java