Is there are way to create automatically

Is there are way to create automatically
0.0 0


the file is look like :

LOCAL_SRC_FILES := main.cpp …/…/…/Classes/AppDelegate.cpp …/…/…/Classes/GameMenu/GameMainMenu.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/…/…/cocos2dx $(LOCAL_PATH)/…/…/…/…/cocos2dx/platform $(LOCAL_PATH)/…/…/…/…/cocos2dx/include $(LOCAL_PATH)/…/…/…/…/CocosDenshion/include $(LOCAL_PATH)/…/…/…/Classes $(LOCAL_PATH)/…/…/…/Classes/GameMenu

so any class i add ,i must modify the file,is any tool can fix that??

help!When I used GLESDebugDraw the compile is fail.

No now, may be you can write a script to do it and share with the community.


OK,i will ,but not today,and i am not so good at shell,may be i will use .exe(windows) or .app(mac os),sorry linux guys :slight_smile:


Include all **.cpp files automatically in
** For in “/Classes” folder (or you must correct the script)
* If I want to rebuild project I resave (this maybe dummy way) or you need to use the “always_rebuild” key (I don’t know it)

define all-cpp-files-under
$(patsubst ./%,%, \
  $(shell cd $(LOCAL_PATH) ; \
          find $(1) -name "*.cpp" -and -not -name ".*") \

define all-subdir-cpp-files
$(call all-cpp-files-under,.)

LOCAL_SRC_FILES += $(call all-subdir-cpp-files)

Maybe I should share this in other place?


it’s good…

Taking photos from camera and gallery

I found “…/HelloWorld/android/jni/” with function list_alldir().
It look like useful for this issue, but don’t used by default… strange.


OK~ I fix to create automatically~
It can find any subdirs and **.cpp that u add in “Classes”
include $
LOCAL_MODULE := game_logic

dirs := $ ~~type d)
cppfilestemp1 := $~~type d)
cppfilestemp2 := $ -name**.cpp)
cppfilestemp3 := $(sort $(cppfilestemp2))
cppfiles := $(subst $(LOCAL_PATH)/,$(cppfilestemp3))

LOCAL_SRC_FILES := $(cppfiles)

LOCAL_C_INCLUDES := $(LOCAL_PATH)/…/…/cocos2dx $(LOCAL_PATH)/…/…/cocos2dx/platform $(LOCAL_PATH)/…/…/cocos2dx/include $(LOCAL_PATH)/…/…/CocosDenshion/include $(LOCAL_PATH)/…/…/cocos2dx/lua_support $(dirs)

It’s for cocos2d-1.0.1-x-0.10.0 !

or u can download file and cover it



Is it okay for .mm classes? cause i have .mm classes on my iphone cocos2d-x project,
and after i modified file. I got this error.

Compile++ thumb : game <=
fatal error: directory compilation terminated.
make: * [obj/local/armeabi/objs-debug/game/////source/states/ClassicGameplay.o] Error 1
ERROR: NDK build failed.


My looks like this:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
FILE_LIST := $(wildcard $(LOCAL_PATH)/…/…/Classes/Actions/*.cpp)
FILE_LIST = $/…/…/Classes/Constants/.cpp)
FILE_LIST *= $/…/…/Classes/Helpers/
FILE_LIST = $/…/…/Classes/GameObjects/.cpp)
FILE_LIST = $/…/…/Classes/Scenes/*.cpp)
= $/…/…/Classes/Singletons/
= $/…/…/Classes/JNICalls/**.cpp)
= $/…/…/Classes/**.cpp)
LOCAL_SRC_FILES := helloworld/main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static
$(call import-module,CocosDenshion/android) $(call import-module,cocos2dx)

Compile all cpp in each folder. It is helpful if you add new cpps and don’t want to add manually (but folders must be). All headers are relatives.



  1. Android don’t understands Obj C language
  2. "name *.cpp" it takes cpp files only


Hi! so… I badly need to convert obj-c codes to c++ D:
Thanks BTW! :smiley:


I attach an image with the error …… If I made any mistake then post for the response


Akas Middha wrote:

I attach an image with the error …… If I made any mistake then post for the response

You are having a permission error. Make sure you run the BAT file with Admin access.


has anyone here have used the file under the jni folder of pre-created android project of cocos2d-x? :slight_smile:


I’ve made a self-updated with Cog utility. It requires python to be installed. If there is interest in such approach I can share it with you guys.


Would you mind if I try your utility? :smiley:


Sure, I’ve put the code to github:
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 on every invocation of That’s pretty quick compared to overall slowness of Eclipse ;)
You can disable automatic update of in and simply run 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 - 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, 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.

I’m using cocos2d-2.1rc0-x-2.1.2 @ March 20.2013

Edit —————

I’ve made a typo in my script, and got it working! If anyone is interested you can see it here :


See the following post (Simplified Chinese)

System will select all cpp files in folders.
But it is needed to make sure the source files in folders are all valid.


I can vouch for Pawel’s script :slight_smile: