fixed setup option position when using narrow font
[rocksndiamonds.git] / build-projects / android / build-scripts / create_manifest.sh
1 #!/bin/bash
2
3 APP_DIR="app"
4 SRC_DIR="$APP_DIR/jni/src"
5 MAIN_DIR="$APP_DIR/src/main"
6
7 BUILD_FILE="$APP_DIR/build.gradle"
8 BUILD_TMPL="$BUILD_FILE.tmpl"
9
10 MANIFEST_FILE="$MAIN_DIR/AndroidManifest.xml"
11 MANIFEST_TMPL="$MANIFEST_FILE.tmpl"
12
13 MAIN_H="$SRC_DIR/main.h"
14
15 VERSION_SUPER=`grep "#define PROGRAM_VERSION_SUPER" $MAIN_H | awk '{print $3}'`
16 VERSION_MAJOR=`grep "#define PROGRAM_VERSION_MAJOR" $MAIN_H | awk '{print $3}'`
17 VERSION_MINOR=`grep "#define PROGRAM_VERSION_MINOR" $MAIN_H | awk '{print $3}'`
18 VERSION_PATCH=`grep "#define PROGRAM_VERSION_PATCH" $MAIN_H | awk '{print $3}'`
19 VERSION_EXTRA=`grep "#define PROGRAM_VERSION_EXTRA" $MAIN_H     \
20     | awk -F\" '{print $2}'                                     \
21     | tr '[A-Z ]' '[a-z-]'`
22
23 UNIQUE_VERSION=`echo "$VERSION_SUPER" | wc -l | awk '{ print $1 }'`
24 if [ "$UNIQUE_VERSION" != "1" ]; then
25     echo "ERROR: program version number ('PROGRAM_VERSION_SUPER') not unique!"
26     exit
27 fi
28
29 VERSION_NAME="$VERSION_SUPER.$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH"
30 VERSION_CODE=$(printf '%d%02d%02d%02d'  \
31     "$VERSION_SUPER"                    \
32     "$VERSION_MAJOR"                    \
33     "$VERSION_MINOR"                    \
34     "$VERSION_PATCH")
35
36 if [ "$VERSION_EXTRA" != "" ]; then
37     VERSION_NAME="$VERSION_NAME$VERSION_EXTRA"
38 fi
39
40 # echo "::: VERSION_NAME == '$VERSION_NAME'"
41 # echo "::: VERSION_CODE == '$VERSION_CODE'"
42
43 cat "$BUILD_TMPL"                                       \
44     | sed -e "s/__VERSION_NAME__/$VERSION_NAME/"        \
45     | sed -e "s/__VERSION_CODE__/$VERSION_CODE/"        \
46     > "$BUILD_FILE"
47
48 cat "$MANIFEST_TMPL"                                    \
49     | sed -e "s/__VERSION_NAME__/$VERSION_NAME/"        \
50     | sed -e "s/__VERSION_CODE__/$VERSION_CODE/"        \
51     > "$MANIFEST_FILE"
52
53 exit 0