mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
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.
This commit is contained in:
parent
7919318be7
commit
c39a85a88d
1
.gitignore
vendored
1
.gitignore
vendored
@ -39,6 +39,7 @@ doc/doxygen_*
|
|||||||
CMakeFiles/*
|
CMakeFiles/*
|
||||||
src/CMakeFiles/*
|
src/CMakeFiles/*
|
||||||
src/Makefile
|
src/Makefile
|
||||||
|
src/android_config_githash.h
|
||||||
src/android_version.h
|
src/android_version.h
|
||||||
src/cmake_config.h
|
src/cmake_config.h
|
||||||
src/cmake_config_githash.h
|
src/cmake_config_githash.h
|
||||||
|
@ -15,6 +15,14 @@ ROOT = $(shell pwd)
|
|||||||
|
|
||||||
GAMES_TO_COPY = minetest_game
|
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
|
# Android Version code
|
||||||
# Increase for each build!
|
# Increase for each build!
|
||||||
@ -161,7 +169,8 @@ endif
|
|||||||
$(OPENAL_TIMESTAMP) $(OGG_TIMESTAMP) \
|
$(OPENAL_TIMESTAMP) $(OGG_TIMESTAMP) \
|
||||||
$(IRRLICHT_TIMESTAMP) $(CURL_TIMESTAMP) \
|
$(IRRLICHT_TIMESTAMP) $(CURL_TIMESTAMP) \
|
||||||
$(OPENSSL_TIMESTAMP) curl_binary \
|
$(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)
|
debug : $(PATHCFGFILE)
|
||||||
export NDEBUG=; \
|
export NDEBUG=; \
|
||||||
@ -773,7 +782,7 @@ clean_assets :
|
|||||||
|
|
||||||
apk: $(PATHCFGFILE) assets $(ICONV_LIB) $(IRRLICHT_LIB) $(CURL_LIB) $(GMP_LIB) $(LEVELDB_TARGET) \
|
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 \
|
$(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 NDEBUG=$$NDEBUG; $(MAKE) manifest; \
|
||||||
export PATH=$$PATH:${SDKFOLDER}/platform-tools:${ANDROID_NDK}; \
|
export PATH=$$PATH:${SDKFOLDER}/platform-tools:${ANDROID_NDK}; \
|
||||||
export ANDROID_HOME=${SDKFOLDER}; \
|
export ANDROID_HOME=${SDKFOLDER}; \
|
||||||
@ -819,44 +828,47 @@ clean_all :
|
|||||||
sleep 1; \
|
sleep 1; \
|
||||||
$(RM) -r gen libs obj deps bin Debug and_env
|
$(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
|
$(ROOT)/jni/src/android_version.h : prep_srcdir
|
||||||
@export VERSION_FILE=${ROOT}/jni/src/android_version.h; \
|
@export VERSION_FILE=${ROOT}/jni/src/android_version.h; \
|
||||||
export VERSION_FILE_NEW=$${VERSION_FILE}.new; \
|
export VERSION_FILE_NEW=$${VERSION_FILE}.new; \
|
||||||
{ \
|
{ \
|
||||||
echo "#ifndef ANDROID_MT_VERSION_H"; \
|
echo "#ifndef ANDROID_MT_VERSION_H"; \
|
||||||
echo "#define ANDROID_MT_VERSION_H"; \
|
echo "#define ANDROID_MT_VERSION_H"; \
|
||||||
export CMAKE_FILE=${ROOT}/../../CMakeLists.txt; \
|
echo "#define VERSION_MAJOR ${VERSION_MAJOR}"; \
|
||||||
export VERSION_MAJOR=$$(cat $${CMAKE_FILE} | \
|
echo "#define VERSION_MINOR ${VERSION_MINOR}"; \
|
||||||
grep ^set\(VERSION_MAJOR\ | sed 's/)/ /' | cut -f2 -d' '); \
|
echo "#define VERSION_PATCH ${VERSION_PATCH}"; \
|
||||||
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_STRING STR(VERSION_MAJOR)\".\"STR(VERSION_MINOR)\
|
echo "#define VERSION_STRING STR(VERSION_MAJOR)\".\"STR(VERSION_MINOR)\
|
||||||
\".\"STR(VERSION_PATCH)"; \
|
\".\"STR(VERSION_PATCH)"; \
|
||||||
echo "#endif"; \
|
echo "#endif"; \
|
||||||
} > $${VERSION_FILE_NEW}; \
|
} > $${VERSION_FILE_NEW}; \
|
||||||
if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
|
if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
|
||||||
echo "android_version.h changed, updating..."; \
|
echo "android_version.h changed, updating..."; \
|
||||||
mv $${VERSION_FILE_NEW} $${VERSION_FILE}; \
|
mv "$${VERSION_FILE_NEW}" "$${VERSION_FILE}"; \
|
||||||
else \
|
else \
|
||||||
rm $${VERSION_FILE_NEW}; \
|
rm "$${VERSION_FILE_NEW}"; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
manifest :
|
manifest :
|
||||||
@VERS_MAJOR=$$(cat ${ROOT}/../../CMakeLists.txt | \
|
@BASE_VERSION="${VERS_MAJOR}.${VERS_MINOR}.${VERS_PATCH}"; \
|
||||||
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"; \
|
|
||||||
if [ "${NDEBUG}x" != "x" ] ; then \
|
if [ "${NDEBUG}x" != "x" ] ; then \
|
||||||
DBG=''; \
|
DBG=''; \
|
||||||
DBG_FLAG="android:debuggable=\"false\""; \
|
DBG_FLAG="android:debuggable=\"false\""; \
|
||||||
|
@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
#include "android_version.h"
|
#include "android_version.h"
|
||||||
|
#include "android_version_githash.h"
|
||||||
#elif defined(USE_CMAKE_CONFIG_H)
|
#elif defined(USE_CMAKE_CONFIG_H)
|
||||||
#include "cmake_config_githash.h"
|
#include "cmake_config_githash.h"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user