LOCAL_PATH := $(call my-dir)
LOCAL_MYDIR = $(LOCAL_PATH)/../../Classes
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos/editor-support)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
#1 定义查找所有cpp文件的宏
define all-cpp-files
$(patsubst ./%,%, $(shell find $(LOCAL_MYDIR) -name "*.cpp"))
endef
#2 定义查找所有c文件的宏,android有默认定义,此处可酌情省略
define all-c-files
$(patsubst ./%,%, $(shell find $(LOCAL_MYDIR) -name "*.c"))
endef
#3 通过查找获取所有工程文件列表
CPP_FILE_LIST := $(call all-cpp-files)
C_FILE_LIST := $(call all-c-files)
#4 加入工程文件,之所以不直接加是需要进行一个LOCAL_PATH的替换
$(warning "prase begin")
LOCAL_SRC_FILES := $(CPP_FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_SRC_FILES += $(C_FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_SRC_FILES += CPP_FILE_LIST
LOCAL_SRC_FILES += C_FILE_LIST
LOCAL_SRC_FILES += $(LOCAL_PATH)/main.cpp
$(warning "prase end")
define all-include-dirs
$(patsubst ./%,%, $(shell find $(LOCAL_MYDIR) -type d))
endef
#5 加入头文件
#LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES := $(call all-include-dirs)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/external
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/cocos/editor-support/
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/cocos/editor-support/cocostudio
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/cocos/editor-support/spine
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/cocos/ui
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/extensions
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/cocos/network
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/external/curl/include/ios
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/external/lua/lua
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../cocos2d/external/lua/tolua
#6 需要链接的系统默认库
#7 加入静态库,加了LOCAL_WHOLE_STATIC_LIBRARIES代表编译器会将静态库完整链接而不会进行删减优化
LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
# LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static
# LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static
LOCAL_WHOLE_STATIC_LIBRARIES += spine_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
LOCAL_WHOLE_STATIC_LIBRARIES += ui_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_network_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static
#8 预编译宏
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS := -DUSE_FILE32API
LOCAL_EXPORT_CFLAGS := -DUSE_FILE32API
#9 声明生成静态库
include $(BUILD_SHARED_LIBRARY)
#10 添加外部导入库目录
#11 添加导入库(基于上一行添加的导入库目录)
$(call import-module,.)
$(call import-module,audio/android)
# $(call import-module,Box2D)
# $(call import-module,editor-support/cocosbuilder)
$(call import-module,editor-support/spine)
$(call import-module,editor-support/cocostudio)
$(call import-module,ui)
$(call import-module,network)
$(call import-module,extensions)
$(call import-module,scripting/lua-bindings)