Cocos2d-x 避免手工输入项目需要编译的cpp文件到Android.mk里

前端之家收集整理的这篇文章主要介绍了Cocos2d-x 避免手工输入项目需要编译的cpp文件到Android.mk里前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

手工输入项目需要编译的cpp文件到Android.mk里的缺点

1)繁琐,如果cpp文件很多,简直无法忍受

2)手工输入过程中容易出现错误

3)如果cpp文件更改名称,需要修改Android.mk文件

。。。。等等

下面的样例代码转自:https://gist.github.com/andyque/6060595

[plain] view plain copy
  1. <spanstyle="font-family:SimHei;font-size:18px;">LOCAL_PATH:=$(callmy-dir)
  2. include$(CLEAR_VARS)
  3. LOCAL_MODULE:=game_shared
  4. LOCAL_MODULE_FILENAME:=libgame
  5. #traverseallthedirectoryandsubdirectory
  6. definewalk
  7. $(wildcard$(1))$(foreache,$(wildcard$(1)/*),$(callwalk,$(e)))
  8. endef
  9. #traverseClassesDirectory
  10. ALLFILES=$(callwalk,$(LOCAL_PATH)/../../Classes)
  11. FILE_LIST:=hellocpp/main.cpp
  12. FILE_LIST+=$(filter%.cpp,$(ALLFILES))
  13. FILE_INCLUDES:=$(shellfind$(LOCAL_PATH)/../../Classes-typed)
  14. #sourcefilewillbecompiled
  15. LOCAL_SRC_FILES:=$(FILE_LIST:$(LOCAL_PATH)/%=%)
  16. LOCAL_C_INCLUDES:=$(LOCAL_PATH)/../../../external/Box2D/\
  17. $(FILE_INCLUDES)\
  18. LOCAL_WHOLE_STATIC_LIBRARIES:=cocos2dx_staticcocosdenshion_staticcocos_extension_staticBox2d_static
  19. include$(BUILD_SHARED_LIBRARY)
  20. $(callimport-module,CocosDenshion/android)\
  21. $(callimport-module,cocos2dx)\
  22. Box2D)</span>

猜你在找的Cocos2d-x相关文章