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

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

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

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

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

。。。。等等

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

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
LOCAL_MODULE := game_shared
 
LOCAL_MODULE_FILENAME := libgame
 
#traverse all the directory and subdirectory
define walk
  $(wildcard $(1)) $(foreach e, $(wildcard $(1)/*), $(call walk, $(e)))
endef
 
#traverse Classes Directory
ALLFILES = $(call walk, $(LOCAL_PATH)/../../Classes)
 
FILE_LIST := hellocpp/main.cpp
FILE_LIST += $(filter %.cpp, $(ALLFILES))
 
FILE_INCLUDES := $(shell find $(LOCAL_PATH)/../../Classes -type d)
 
#source file will be compiled
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
 
                   
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../external/Box2D/ \
	$(FILE_INCLUDES) \
 
 
 
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static cocosdenshion_static cocos_extension_static box2d_static
            
include $(BUILD_SHARED_LIBRARY)
 
$(call import-module,CocosDenshion/android) \
$(call import-module,cocos2dx) \
$(call import-module,extensions) \
$(call import-module,external/Box2D)

你可能感兴趣的:(Cocos2d-x 避免手工输入项目需要编译的cpp文件到Android.mk里)