prepared code to support more tape actions than players
[rocksndiamonds.git] / build-projects / android / build-scripts / create_manifest.sh
1 #!/bin/bash
2
3 BASE_DIR="jni"
4
5 MANIFEST_FILE="AndroidManifest.xml"
6 MANIFEST_TMPL="$MANIFEST_FILE.tmpl"
7
8 MAIN_H="$BASE_DIR/src/main.h"
9
10 VERSION_SUPER=`grep "#define PROGRAM_VERSION_SUPER" $MAIN_H | awk '{print $3}'`
11 VERSION_MAJOR=`grep "#define PROGRAM_VERSION_MAJOR" $MAIN_H | awk '{print $3}'`
12 VERSION_MINOR=`grep "#define PROGRAM_VERSION_MINOR" $MAIN_H | awk '{print $3}'`
13 VERSION_PATCH=`grep "#define PROGRAM_VERSION_PATCH" $MAIN_H | awk '{print $3}'`
14 VERSION_EXTRA=`grep "#define PROGRAM_VERSION_EXTRA" $MAIN_H     \
15     | awk -F\" '{print $2}'                                     \
16     | tr '[A-Z ]' '[a-z-]'`
17
18 UNIQUE_VERSION=`echo "$VERSION_SUPER" | wc -l | awk '{ print $1 }'`
19 if [ "$UNIQUE_VERSION" != "1" ]; then
20     echo "ERROR: program version number ('PROGRAM_VERSION_SUPER') not unique!"
21     exit
22 fi
23
24 VERSION_NAME="$VERSION_SUPER.$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
25 VERSION_CODE=$(printf '%d%02d%02d%02d'  \
26     "$VERSION_SUPER"                    \
27     "$VERSION_MAJOR"                    \
28     "$VERSION_MINOR"                    \
29     "$VERSION_PATCH")
30
31 if [ "$VERSION_EXTRA" != "" ]; then
32     VERSION_NAME="$VERSION_NAME$VERSION_EXTRA"
33 fi
34
35 # echo "::: VERSION_NAME == '$VERSION_NAME'"
36 # echo "::: VERSION_CODE == '$VERSION_CODE'"
37
38 cat "$MANIFEST_TMPL"                                    \
39     | sed -e "s/__VERSION_NAME__/$VERSION_NAME/"        \
40     | sed -e "s/__VERSION_CODE__/$VERSION_CODE/"        \
41     > "$MANIFEST_FILE"
42
43 exit 0