Cocos2dx-Android 之Makefile通用高级写法

前端之家收集整理的这篇文章主要介绍了Cocos2dx-Android 之Makefile通用高级写法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

LOCAL_PATH := $(call my-dir)


include $(CLEAR_VARS)


LOCAL_MODULE := cocos2dcpp_shared


LOCAL_MODULE_FILENAME := libcocos2dcpp



###############################################################################

##########################手动遍历文件夹以及子目录##############################

##########################这是第一种很麻烦的写法################################

#XLOCAL_C_INCLUDES := \

# $(LOCAL_PATH)/hellocpp \

# $(LOCAL_PATH)/../../Classes

#

#XLOCAL_CPPS := \

# $(wildcard $(LOCAL_PATH)/hellocpp/*.cpp) \

# $(wildcard $(LOCAL_PATH)/../../Classes/*.c) \

# $(wildcard $(LOCAL_PATH)/../../Classes/*.cpp)

#

#XLOCAL_SRC_FILES := $(XLOCAL_CPPS:$(LOCAL_PATH)/%=%)

#

#LOCAL_C_INCLUDES += $(XLOCAL_C_INCLUDES)

#LOCAL_SRC_FILES := $(XLOCAL_SRC_FILES)

###############################################################################



###############################################################################

##########################自动遍历文件夹以及子目录##############################

##########################这是第二种比较方便的写法##############################

# 遍历目录及子目录的函数

#define walk

# $(wildcard $(1)) $(foreach e,$(wildcard $(1)/*),$(call walk,$(e)))

#endef

#

## 遍历Classes目录

#ALLFILES = $(call walk,$(LOCAL_PATH)/../../Classes)

#

#FILE_LIST := hellocpp/main.cpp

## 从所有文件提取出所有.cpp文件

#FILE_LIST += $(filter %.cpp,$(ALLFILES))

#

#LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)

#LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes \

# $(LOCAL_PATH)/../../Classes/LogClass

###############################################################################



###############################################################################

##########################自动遍历文件夹以及子目录(源文件和头文件)################

##########################这是第三种之相对最方便的写法###########################

# 配置自己的源文件目录和源文件后缀名

APP_FILES_PATH := $(LOCAL_PATH) \

$(LOCAL_PATH)/../../Classes

APP_FILES_SUFFIX := %.cpp %.c

# 递归遍历目录下的所有的文件

rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

# 获取相应的源文件

APP_ALL_FILES := $(foreach src_path,$(APP_FILES_PATH),$(src_path),*.*) )

APP_ALL_FILES := $(APP_ALL_FILES:$(APP_CPP_PATH)/./%=$(APP_CPP_PATH)%)

APP_SRC_LIST := $(filter $(APP_FILES_SUFFIX),$(APP_ALL_FILES))

APP_SRC_LIST := $(APP_SRC_LIST:$(LOCAL_PATH)/%=%)

# 去除字串的重复单词

define uniq =

$(eval seen :=)

$(foreach _,$1,$(if $(filter $_,${seen}),$(eval seen += $_)))

${seen}

endef


# 递归遍历获取所有目录

APP_ALL_DIRS := $(dir $(foreach src_path,*/) ) )

APP_ALL_DIRS := $(call uniq,$(APP_ALL_DIRS))

# 赋值给NDK编译系统

LOCAL_SRC_FILES := $(APP_SRC_LIST)

LOCAL_C_INCLUDES := $(APP_ALL_DIRS)

###############################################################################




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 += cocos_network_static

LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static



include $(BUILD_SHARED_LIBRARY)


$(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,network)

$(call import-module,extensions)

原文链接:https://www.f2er.com/cocos2dx/341736.html

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