forked from Mirrorlandia_minetest/minetest
Android: speed up rebuild, and prevent race condition fail
Speeding up rebuild: Before, we've written the android_version.h file at every rebuild. As it thought the file's content has changed, make has rebuilt files in the source tree that depended on that header file during rebuild, causing lots of files being rebuilt without there being a reason. The reasoning of make can be observed by passing -d and V=1 params to the ndk-build command. You then got logging entries like: Prerequisite `jni/src/android_version.h' is newer than target `obj/local/armeabi-v7a-hard/objs-debug/minetest/jni/src/areastore.o'. Preventing race condition build fail: Before, there was a race condition, where, if the prep_srcdir target was executed in parallel with the $(ROOT)/jni/src/android_version.h one, it could happen that the jni/src directory was nonexistent, and we were trying to write into a file inside. This resulted in a build failue: /bin/sh: 1: cannot create [...]/jni/src/android_version.h: Directory nonexistent Additionally, we now don't remove the link to src/ needlessly anymore. Keeping this wouldn't have affected the rebuild, but this way its more proper.
This commit is contained in:
parent
7217fd32eb
commit
e29b61ecd4
@ -791,8 +791,9 @@ apk: $(PATHCFGFILE) assets $(ICONV_LIB) $(IRRLICHT_LIB) $(CURL_LIB) $(GMP_LIB) $
|
|||||||
echo "You can install it with \`adb install -r bin/Minetest-$$BUILD_TYPE.apk\`"
|
echo "You can install it with \`adb install -r bin/Minetest-$$BUILD_TYPE.apk\`"
|
||||||
|
|
||||||
prep_srcdir :
|
prep_srcdir :
|
||||||
@rm ${ROOT}/jni/src; \
|
@if [ ! -e ${ROOT}/jni/src ]; then \
|
||||||
ln -s ${ROOT}/../../src ${ROOT}/jni/src
|
ln -s ${ROOT}/../../src ${ROOT}/jni/src; \
|
||||||
|
fi
|
||||||
|
|
||||||
clean_apk : manifest
|
clean_apk : manifest
|
||||||
@export PATH=$$PATH:${SDKFOLDER}platform-tools:${ANDROID_NDK}; \
|
@export PATH=$$PATH:${SDKFOLDER}platform-tools:${ANDROID_NDK}; \
|
||||||
@ -818,8 +819,10 @@ 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.h :
|
$(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 "#ifndef ANDROID_MT_VERSION_H"; \
|
||||||
echo "#define ANDROID_MT_VERSION_H"; \
|
echo "#define ANDROID_MT_VERSION_H"; \
|
||||||
export CMAKE_FILE=${ROOT}/../../CMakeLists.txt; \
|
export CMAKE_FILE=${ROOT}/../../CMakeLists.txt; \
|
||||||
@ -838,7 +841,13 @@ $(ROOT)/jni/src/android_version.h :
|
|||||||
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"; \
|
||||||
} > ${ROOT}/jni/src/android_version.h
|
} > $${VERSION_FILE_NEW}; \
|
||||||
|
if ! cmp -s $${VERSION_FILE} $${VERSION_FILE_NEW}; then \
|
||||||
|
echo "android_version.h changed, updating..."; \
|
||||||
|
mv $${VERSION_FILE_NEW} $${VERSION_FILE}; \
|
||||||
|
else \
|
||||||
|
rm $${VERSION_FILE_NEW}; \
|
||||||
|
fi
|
||||||
|
|
||||||
manifest :
|
manifest :
|
||||||
@VERS_MAJOR=$$(cat ${ROOT}/../../CMakeLists.txt | \
|
@VERS_MAJOR=$$(cat ${ROOT}/../../CMakeLists.txt | \
|
||||||
|
Loading…
Reference in New Issue
Block a user