首页 > 移动平台 > 详细

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

时间:2016-01-10 15:37:35      阅读:227      评论:0      收藏:0      [点我收藏+]

还记得上一篇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)
$(call import-module,audio/android)
$(call import-module,Box2D)
$(call import-module,extensions)				# 导入 extensions 模块
$(call import-module,editor-support/cocostudio)			# 导入 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, $(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)/%=%)

其它部分不变。

恩然后即可了。


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


LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := cocos2dcpp_shared

LOCAL_MODULE_FILENAME := libcocos2dcpp

# 遍历文件夹及子文件夹的函数
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_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)
$(call import-module,audio/android)
$(call import-module,Box2D)
$(call import-module,extensions)						# 导入 extensions 模块
$(call import-module,editor-support/cocostudio)			# 导入 cocostudio 模块




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

原文:http://www.cnblogs.com/gcczhongduan/p/5118505.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!