Include all **.cpp files automatically in Android.mk:
** For Android.mk in “/Classes” folder (or you must correct the script)
* If I want to rebuild project I resave Android.mk (this maybe dummy way) or you need to use the “always_rebuild” key (I don’t know it)
OK~ I fix android.mk to create android.mk automatically~
It can find any subdirs and **.cpp that u add in “Classes”
<pre>
LOCAL_PATH := $
include $
LOCAL_MODULE := game_logic
I’ve made a self-updated Android.mk with Cog utility. It requires python to be installed. If there is interest in such approach I can share it with you guys.
Sure, I’ve put the code to github: https://github.com/bialix/cog-for-android.mk
It’s based on HelloWorld sample from cocos2dx sources (I have v.2.0.1 here but I think it should work for newer versions too).
You need Python 2.6 or higher to be available for your build environment. If you have to use older versions of Python you may need to downgrade Cog utility itself, see it’s homepage for details.
My script tries to update Android.mk on every invocation of build_native.sh. That’s pretty quick compared to overall slowness of Eclipse ;)
You can disable automatic update of Android.mk in build_native.sh and simply run update-androidmk.sh script from jni subdir manually if you like.
Also my script tries to collect all subfloders in Classes where C++ files are located and update LOCAL_C_INCLUDES so you don’t have to worry about #include from different folders . If you need to disable this you need simply delete couple of lines in Android.mk - I’ve left a comment in the appropriate place.
Using power of Python it’s easy to create more sophisticated files list collector/makefile generator, e.g. exclude some files from Android build etc.
I’ve tried FoXx WeLl approach, and before that I’ve tried writing my own script to generate the Android.mk, but anytime I introduced an automatically generated file to my project it threw an error, saying that main.cpp cannot find “#include”AppDelegate.h“”. Before introducing the file, everything worked thine, the project built & run.