Created
August 14, 2014 08:50
-
-
Save xxxzhi/13177789623aadeb138d to your computer and use it in GitHub Desktop.
这是在cocos2d-x 中 使用下面这一部分能够自动包含 class 目录下面的源文件,以及 jni/ 下面的源文件。目录递归包含。摘自:http://blog.ready4go.com/blog/2013/10/12/update-android-dot-mk-with-local-src-files-and-local-c-includes/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 配置自己的源文件目录和源文件后缀名 | |
MY_FILES_PATH := $(LOCAL_PATH) \ | |
$(LOCAL_PATH)/../../Classes | |
MY_FILES_SUFFIX := %.cpp %.c | |
# 递归遍历目录下的所有的文件 | |
rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2)) | |
# 获取相应的源文件 | |
MY_ALL_FILES := $(foreach src_path,$(MY_FILES_PATH), $(call rwildcard,$(src_path),*.*) ) | |
MY_ALL_FILES := $(MY_ALL_FILES:$(MY_CPP_PATH)/./%=$(MY_CPP_PATH)%) | |
MY_SRC_LIST := $(filter $(MY_FILES_SUFFIX),$(MY_ALL_FILES)) | |
MY_SRC_LIST := $(MY_SRC_LIST:$(LOCAL_PATH)/%=%) | |
# 去除字串的重复单词 | |
define uniq = | |
$(eval seen :=) | |
$(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_))) | |
${seen} | |
endef | |
# 递归遍历获取所有目录 | |
MY_ALL_DIRS := $(dir $(foreach src_path,$(MY_FILES_PATH), $(call rwildcard,$(src_path),*/) ) ) | |
MY_ALL_DIRS := $(call uniq,$(MY_ALL_DIRS)) | |
# 赋值给NDK编译系统 | |
LOCAL_SRC_FILES := $(MY_SRC_LIST) | |
LOCAL_C_INCLUDES := $(MY_ALL_DIRS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment