2010-01-12 14:15:47 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-02-14 08:35:41 +01:00
|
|
|
set -e -u
|
|
|
|
|
2014-05-19 16:10:29 +02:00
|
|
|
STRINGS_HASH=""
|
|
|
|
|
2014-04-28 05:03:08 +02:00
|
|
|
usage() {
|
|
|
|
echo "usage: $0 <variant> <relay_vers> <chatSupported> <thumbSupported>"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
[ $# -eq 4 ] || usage
|
|
|
|
|
2014-04-19 04:25:40 +02:00
|
|
|
VARIANT=$1
|
|
|
|
CLIENT_VERS_RELAY=$2
|
|
|
|
CHAT_SUPPORTED=$3
|
|
|
|
THUMBNAIL_SUPPORTED=$4
|
2012-02-14 08:35:41 +01:00
|
|
|
|
2014-04-19 04:25:40 +02:00
|
|
|
BUILD_DIR=$(basename $(pwd))
|
2010-01-12 14:15:47 +01:00
|
|
|
cd $(dirname $0)
|
2014-04-19 04:25:40 +02:00
|
|
|
cd ../
|
2010-01-12 14:15:47 +01:00
|
|
|
|
2014-04-19 04:25:40 +02:00
|
|
|
GITVERSION=$(../scripts/gitversion.sh)
|
2010-02-28 19:17:35 +01:00
|
|
|
|
2014-05-19 16:10:29 +02:00
|
|
|
# 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
|
2010-06-05 16:55:40 +02:00
|
|
|
# TODO: deal with case where there's no hash available -- exported
|
|
|
|
# code maybe? Better: gitversion.sh does that.
|
|
|
|
|
2014-04-19 04:25:40 +02:00
|
|
|
cat <<EOF > ${BUILD_DIR}/res/values/git_string.xml
|
2010-06-05 16:55:40 +02:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<!-- auto-generated; do not edit -->
|
|
|
|
|
|
|
|
<resources>
|
2011-12-22 03:35:14 +01:00
|
|
|
<string name="git_rev">$GITVERSION</string>
|
2010-06-05 16:55:40 +02:00
|
|
|
</resources>
|
2010-01-12 14:15:47 +01:00
|
|
|
EOF
|
|
|
|
|
2010-06-05 17:24:43 +02:00
|
|
|
# Eventually this should pick up a tag if we're at one. That'll be
|
|
|
|
# the way to mark a release
|
2014-05-19 16:15:21 +02:00
|
|
|
SHORTVERS="$(git describe --always $GITVERSION 2>/dev/null || echo ${GITVERSION}+)"
|
2014-10-13 16:20:17 +02:00
|
|
|
GITHASH=$(git rev-parse --verify HEAD)
|
2010-06-05 17:24:43 +02:00
|
|
|
|
2014-04-19 04:25:40 +02:00
|
|
|
cat <<EOF > ${BUILD_DIR}/src/org/eehouse/android/${VARIANT}/BuildConstants.java
|
2014-04-30 12:29:47 +02:00
|
|
|
// auto-generated (by $(basename $0)); do not edit
|
2012-02-14 08:35:41 +01:00
|
|
|
package org.eehouse.android.${VARIANT};
|
2013-11-15 06:56:24 +01:00
|
|
|
class BuildConstants {
|
|
|
|
public static final String GIT_REV = "$SHORTVERS";
|
2014-10-13 16:20:17 +02:00
|
|
|
public static final String GIT_HASH = "$GITHASH";
|
2014-04-30 12:29:47 +02:00
|
|
|
public static final String STRINGS_HASH = "$STRINGS_HASH";
|
2013-08-20 17:42:12 +02:00
|
|
|
public static final short CLIENT_VERS_RELAY = $CLIENT_VERS_RELAY;
|
2013-09-12 07:18:00 +02:00
|
|
|
public static final boolean CHAT_SUPPORTED = $CHAT_SUPPORTED;
|
2013-10-29 14:49:06 +01:00
|
|
|
public static final boolean THUMBNAIL_SUPPORTED = $THUMBNAIL_SUPPORTED;
|
2014-03-07 07:11:13 +01:00
|
|
|
public static final String BUILD_STAMP = "$(date +'%F at %R %Z')";
|
2010-06-05 17:24:43 +02:00
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2010-06-05 16:55:40 +02:00
|
|
|
# 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.)
|
2014-04-19 04:25:40 +02:00
|
|
|
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
|