OSDN Git Service

Add all-cpp-files-under
authorDan Willemsen <dwillemsen@google.com>
Tue, 29 Sep 2015 23:26:28 +0000 (16:26 -0700)
committerDan Willemsen <dwillemsen@google.com>
Tue, 13 Oct 2015 23:14:53 +0000 (16:14 -0700)
There are multiple versions of this in the tree. Let's standardize on
one that will work for everyone, and will sort the results.

Bug: 24204119
Change-Id: I09fcd80e1e8e35e64d8a8a62bbc096f87b02603f

core/definitions.mk

index bc284ae..0ea7040 100644 (file)
@@ -219,6 +219,29 @@ $(call all-c-files-under,.)
 endef
 
 ###########################################################
+## Find all of the cpp files under the named directories.
+## LOCAL_CPP_EXTENSION is respected if set.
+## Meant to be used like:
+##    SRC_FILES := $(call all-cpp-files-under,src tests)
+###########################################################
+
+define all-cpp-files-under
+$(sort $(patsubst ./%,%, \
+  $(shell cd $(LOCAL_PATH) ; \
+          find -L $(1) -name "*$(or $(LOCAL_CPP_EXTENSION),.cpp)" -and -not -name ".*") \
+ ))
+endef
+
+###########################################################
+## Find all of the cpp files from here.  Meant to be used like:
+##    SRC_FILES := $(call all-subdir-cpp-files)
+###########################################################
+
+define all-subdir-cpp-files
+$(call all-cpp-files-under,.)
+endef
+
+###########################################################
 ## Find all files named "I*.aidl" under the named directories,
 ## which must be relative to $(LOCAL_PATH).  The returned list
 ## is relative to $(LOCAL_PATH).