手工输入项目需要编译的cpp文件到Android.mk里的缺点
1)繁琐,如果cpp文件很多,简直无法忍受
2)手工输入过程中容易出现错误
3)如果cpp文件更改名称,需要修改Android.mk文件
。。。。等等
下面的样例代码转自:https://gist.github.com/andyque/6060595
- <spanstyle="font-family:SimHei;font-size:18px;">LOCAL_PATH:=$(callmy-dir)
- include$(CLEAR_VARS)
- LOCAL_MODULE:=game_shared
- LOCAL_MODULE_FILENAME:=libgame
- #traverseallthedirectoryandsubdirectory
- definewalk
- $(wildcard$(1))$(foreache,$(wildcard$(1)/*),$(callwalk,$(e)))
- endef
- #traverseClassesDirectory
- ALLFILES=$(callwalk,$(LOCAL_PATH)/../../Classes)
- FILE_LIST:=hellocpp/main.cpp
- FILE_LIST+=$(filter%.cpp,$(ALLFILES))
- FILE_INCLUDES:=$(shellfind$(LOCAL_PATH)/../../Classes-typed)
- #sourcefilewillbecompiled
- LOCAL_SRC_FILES:=$(FILE_LIST:$(LOCAL_PATH)/%=%)
- LOCAL_C_INCLUDES:=$(LOCAL_PATH)/../../../external/Box2D/\
- $(FILE_INCLUDES)\
- LOCAL_WHOLE_STATIC_LIBRARIES:=cocos2dx_staticcocosdenshion_staticcocos_extension_staticBox2d_static
- include$(BUILD_SHARED_LIBRARY)
- $(callimport-module,CocosDenshion/android)\
- $(callimport-module,cocos2dx)\
- Box2D)</span>