diff options
author | Dan Willemsen <dwillemsen@google.com> | 2015-10-12 15:26:52 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2015-10-13 16:14:57 -0700 |
commit | 57a64e015c0dd670f9adf5a2016526678ce96a1e (patch) | |
tree | 3fc03651106d774fea3e16d9e1fca70ae5061884 /core/definitions.mk | |
parent | 7a74e5ee0e6c41395493d9259ccfff80717a4eaf (diff) | |
download | build-57a64e015c0dd670f9adf5a2016526678ce96a1e.zip build-57a64e015c0dd670f9adf5a2016526678ce96a1e.tar.gz build-57a64e015c0dd670f9adf5a2016526678ce96a1e.tar.bz2 |
Add all-named-(dirs|files)-under and related
To consolidate the number of places that we're using 'find' in the tree,
add some more helpers:
all-named-dirs-under
all-subdir-named-dirs
all-named-files-under
all-subdir-named-files
This change also makes many of the current helpers use these helpers
instead of using their own implementation.
The 'dirs' helpers are using '-type d' so that they only output
directories. It's probably safe to use '-type f' for the files helpers,
but that increased the kati load time by ~20%.
Bug: 24204119
Change-Id: I3312e2fe8c146f10955e1d986ad15d9c8be494e1
Diffstat (limited to 'core/definitions.mk')
-rw-r--r-- | core/definitions.mk | 84 |
1 files changed, 50 insertions, 34 deletions
diff --git a/core/definitions.mk b/core/definitions.mk index 0ea7040..9dea18c 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -175,16 +175,53 @@ $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1)))) endef ########################################################### +## Find all of the directories under the named directories with +## the specified name. +## Meant to be used like: +## INC_DIRS := $(call all-named-dirs-under,inc,.) +########################################################### + +define all-named-dirs-under +$(call find-subdir-files,$(2) -type d -name "$(1)") +endef + +########################################################### +## Find all the directories under the current directory that +## haves name that match $(1) +########################################################### + +define all-subdir-named-dirs +$(call all-named-dirs-under,$(1),.) +endef + +########################################################### +## Find all of the files under the named directories with +## the specified name. +## Meant to be used like: +## SRC_FILES := $(call all-named-files-under,*.h,src tests) +########################################################### + +define all-named-files-under +$(call find-files-in-subdirs,$(LOCAL_PATH),"$(1)",$(2)) +endef + +########################################################### +## Find all of the files under the current directory with +## the specified name. +########################################################### + +define all-subdir-named-files +$(call all-named-files-under,$(1),.) +endef + +########################################################### ## Find all of the java files under the named directories. ## Meant to be used like: ## SRC_FILES := $(call all-java-files-under,src tests) ########################################################### define all-java-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "*.java" -and -not -name ".*") \ - )) +$(call all-named-files-under,*.java,$(1)) endef ########################################################### @@ -203,10 +240,7 @@ endef ########################################################### define all-c-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "*.c" -and -not -name ".*") \ - )) +$(call all-named-files-under,*.c,$(1)) endef ########################################################### @@ -248,10 +282,7 @@ endef ########################################################### define all-Iaidl-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "I*.aidl" -and -not -name ".*") \ - )) +$(call all-named-files-under,I*.aidl,$(1)) endef ########################################################### @@ -269,10 +300,7 @@ endef ########################################################### define all-logtags-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "*.logtags" -and -not -name ".*") \ - )) +$(call all-named-files-under,*.logtags,$(1)) endef ########################################################### @@ -282,10 +310,7 @@ endef ########################################################### define all-proto-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "*.proto" -and -not -name ".*") \ - )) +$(call all-named-files-under,*.proto,$(1)) endef ########################################################### @@ -295,10 +320,7 @@ endef ########################################################### define all-renderscript-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") \ - )) +$(call find-subdir-files,$(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*") endef ########################################################### @@ -308,10 +330,7 @@ endef ########################################################### define all-S-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "*.S" -and -not -name ".*") \ - )) +$(call all-named-files-under,*.S,$(1)) endef ########################################################### @@ -321,10 +340,7 @@ endef ########################################################### define all-html-files-under -$(sort $(patsubst ./%,%, \ - $(shell cd $(LOCAL_PATH) ; \ - find -L $(1) -name "*.html" -and -not -name ".*") \ - )) +$(call all-named-files-under,*.html,$(1)) endef ########################################################### @@ -375,11 +391,11 @@ endef ########################################################### define find-other-java-files - $(call find-subdir-files,$(1) -name "*.java" -and -not -name ".*") +$(call all-java-files-under,$(1)) endef define find-other-html-files - $(call find-subdir-files,$(1) -name "*.html" -and -not -name ".*") +$(call all-html-files-under,$(1)) endef ########################################################### |