cocos2d-x 3.0 android mk文件 之 自动遍历*.cpp文件

前端之家收集整理的这篇文章主要介绍了cocos2d-x 3.0 android mk文件 之 自动遍历*.cpp文件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

时间2014-05-13 16:16:34CSDN博客

还记得上一篇android mk 文件的写法吗?传送门,

我们需要手动去添加 cpp文件,如果cpp一多,那不是要累死?

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

LOCAL_SRC_FILES := hellocpp/main.cpp \
  ../../Classes/AppDelegate.cpp \
  ../../Classes/ClipingNodeLayer.cpp\
  ../../Classes/MainScene.cpp\
  ../../Classes/MenuTab.cpp


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

LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += Box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static          # 添加 cocos_extension 静态库
LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static		# 添加 cocostudio 静态库


include $(BUILD_SHARED_LIBRARY)

$(call import-module,2d)
dio/android)
Box2D)
# 导入 extensions 模块
dio)			# 导入 cocostudio 模块

看了网上许多大神的博客,才发现还可以这样子自动遍历cpp,比如上面这个mk文件,只需要把

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../Classes/AppDelegate.cpp \
                   ../../Classes/ClipingNodeLayer.cpp\
                   ../../Classes/MainScene.cpp\
                   ../../Classes/MenuTab.cpp
改为
# 遍历目录及子目录的函数
define walk
  $(wildcard $(1)) $(foreach e,1)/*),128)">$(call walk,128)">$(e)))
endef

# 遍历Classes目录
ALLFILES = $(LOCAL_PATH)/../../Classes)
           
FILE_LIST := hellocpp/main.cpp
# 从所有文件提取出所有.cpp文件
FILE_LIST += $(filter %.cpp,128)">$(ALLFILES))

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

其他部分不变。恩然后就行了。。

改完之后完整android mk 文件如下:

:= libcocos2dcpp

$(foreach e,153)">1)/*),136); font-style:italic"># 遍历Classes目录
ALLFILES = /../Classes)
           
FILE_LIST := hellocpp/main.cpp
# 从所有文件提取出所有.cpp文件
FILE_LIST += $(filter %.cpp,128)">$(ALLFILES))

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


LOCAL_C_INCLUDES := cocos2dx_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static
LOCAL_WHOLE_STATIC_LIBRARIES += Box2d_static
LOCAL_WHOLE_STATIC_LIBRARIES += cocos_extension_static  # 导入 cocostudio 模块
原文链接:https://www.f2er.com/cocos2dx/345323.html

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