diff options
author | est31 <MTest31@outlook.com> | 2015-07-31 16:38:36 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-08-01 20:42:07 +0200 |
commit | c39a85a88d1f905014c1ced6b87638cdb01e6ddf (patch) | |
tree | d30e5ffda258321f944d2833de363412900fca46 /build/android/Makefile | |
parent | 7919318be715e3bf60f01b7c63816a3e5802176d (diff) | |
download | minetest-c39a85a88d1f905014c1ced6b87638cdb01e6ddf.tar.gz minetest-c39a85a88d1f905014c1ced6b87638cdb01e6ddf.tar.bz2 minetest-c39a85a88d1f905014c1ced6b87638cdb01e6ddf.zip |
Android: Add githash header to spare rebuilds after new commits
Before, android_version.h got changed at every new commit. Now, we
only change it with new minetest releases. Analogous to how cmake
does it, we add an android_version_githash.h file that communicates
the git hash to C++ code.
Also, unify VERS_MAJOR, VERS_MINOR and VERS_PATCH variable
calculation inside the whole makefile.
Diffstat (limited to 'build/android/Makefile')
-rw-r--r-- | build/android/Makefile | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/build/android/Makefile b/build/android/Makefile index 055386361..4ccca56b5 100644 --- a/build/android/Makefile +++ b/build/android/Makefile @@ -15,6 +15,14 @@ ROOT = $(shell pwd) GAMES_TO_COPY = minetest_game + +VERSION_MAJOR := $(shell cat $(ROOT)/../../CMakeLists.txt | \ + grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | cut -f2 -d' ') +VERSION_MINOR := $(shell cat $(ROOT)/../../CMakeLists.txt | \ + grep ^set\(VERSION_MINOR\ | sed 's/)/ /' | cut -f2 -d' ') +VERSION_PATCH := $(shell cat $(ROOT)/../../CMakeLists.txt | \ + grep ^set\(VERSION_PATCH\ | sed 's/)/ /' | cut -f2 -d' ') + ################################################################################ # Android Version code # Increase for each build! @@ -161,7 +169,8 @@ endif $(OPENAL_TIMESTAMP) $(OGG_TIMESTAMP) \ $(IRRLICHT_TIMESTAMP) $(CURL_TIMESTAMP) \ $(OPENSSL_TIMESTAMP) curl_binary \ - $(ROOT)/jni/src/android_version.h + $(ROOT)/jni/src/android_version.h \ + $(ROOT)/jni/src/android_version_githash.h debug : $(PATHCFGFILE) export NDEBUG=; \ @@ -773,7 +782,7 @@ clean_assets : apk: $(PATHCFGFILE) assets $(ICONV_LIB) $(IRRLICHT_LIB) $(CURL_LIB) $(GMP_LIB) $(LEVELDB_TARGET) \ $(OPENAL_LIB) $(OGG_LIB) prep_srcdir $(ROOT)/jni/src/android_version.h \ - sqlite3_download + $(ROOT)/jni/src/android_version_githash.h sqlite3_download @export NDEBUG=$$NDEBUG; $(MAKE) manifest; \ export PATH=$$PATH:${SDKFOLDER}/platform-tools:${ANDROID_NDK}; \ export ANDROID_HOME=${SDKFOLDER}; \ @@ -819,44 +828,47 @@ clean_all : sleep 1; \ $(RM) -r gen libs obj deps bin Debug and_env +$(ROOT)/jni/src/android_version_githash.h : prep_srcdir + @export VERSION_FILE=${ROOT}/jni/src/android_version_githash.h; \ + export VERSION_FILE_NEW=$${VERSION_FILE}.new; \ + { \ + echo "#ifndef ANDROID_MT_VERSION_GITHASH_H"; \ + echo "#define ANDROID_MT_VERSION_GITHASH_H"; \ + export GITHASH=$$(git rev-parse --short=8 HEAD); \ + export VERSION_STR="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"; \ + echo "#define VERSION_GITHASH \"$$VERSION_STR-$$GITHASH-Android\""; \ + echo "#endif"; \ + } > "$${VERSION_FILE_NEW}"; \ + if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \ + echo "android_version_githash.h changed, updating..."; \ + mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \ + else \ + rm "$${VERSION_FILE_NEW}"; \ + fi + + $(ROOT)/jni/src/android_version.h : prep_srcdir @export VERSION_FILE=${ROOT}/jni/src/android_version.h; \ export VERSION_FILE_NEW=$${VERSION_FILE}.new; \ { \ echo "#ifndef ANDROID_MT_VERSION_H"; \ echo "#define ANDROID_MT_VERSION_H"; \ - export CMAKE_FILE=${ROOT}/../../CMakeLists.txt; \ - export VERSION_MAJOR=$$(cat $${CMAKE_FILE} | \ - grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | cut -f2 -d' '); \ - export VERSION_MINOR=$$(cat $${CMAKE_FILE} | \ - grep ^set\(VERSION_MINOR\ | sed 's/)/ /' | cut -f2 -d' '); \ - export VERSION_PATCH=$$(cat $${CMAKE_FILE} | \ - grep ^set\(VERSION_PATCH\ | sed 's/)/ /' | cut -f2 -d' '); \ - echo "#define VERSION_MAJOR $${VERSION_MAJOR}"; \ - echo "#define VERSION_MINOR $${VERSION_MINOR}"; \ - echo "#define VERSION_PATCH $${VERSION_PATCH}"; \ - export GITHASH=$$(git rev-parse --short=8 HEAD); \ - export VERSION_STR="$${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_PATCH}";\ - echo "#define VERSION_GITHASH \"$$VERSION_STR-$$GITHASH-Android\""; \ + echo "#define VERSION_MAJOR ${VERSION_MAJOR}"; \ + echo "#define VERSION_MINOR ${VERSION_MINOR}"; \ + echo "#define VERSION_PATCH ${VERSION_PATCH}"; \ echo "#define VERSION_STRING STR(VERSION_MAJOR)\".\"STR(VERSION_MINOR)\ \".\"STR(VERSION_PATCH)"; \ echo "#endif"; \ } > $${VERSION_FILE_NEW}; \ if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \ echo "android_version.h changed, updating..."; \ - mv $${VERSION_FILE_NEW} $${VERSION_FILE}; \ + mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \ else \ - rm $${VERSION_FILE_NEW}; \ + rm "$${VERSION_FILE_NEW}"; \ fi manifest : - @VERS_MAJOR=$$(cat ${ROOT}/../../CMakeLists.txt | \ - grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | awk '{print $$2;}'); \ - VERS_MINOR=$$(cat ${ROOT}/../../CMakeLists.txt | \ - grep ^set\(VERSION_MINOR\ | sed 's/)/ /' | awk '{print $$2;}'); \ - VERS_PATCH=$$(cat ${ROOT}/../../CMakeLists.txt | \ - grep ^set\(VERSION_PATCH\ | sed 's/)/ /' | awk '{print $$2;}'); \ - BASE_VERSION="$$VERS_MAJOR.$$VERS_MINOR.$$VERS_PATCH"; \ + @BASE_VERSION="${VERS_MAJOR}.${VERS_MINOR}.${VERS_PATCH}"; \ if [ "${NDEBUG}x" != "x" ] ; then \ DBG=''; \ DBG_FLAG="android:debuggable=\"false\""; \ |