Speed up lunch/tapas/etc. shell utility functions.
1. Combined ~10 calls to the make build system to only one.
We added a phony target "dump-many-vars" to the build system to dump
"<var>=<value>" pairs. We then store the pairs as shell variables.
With this cache get_build_var/get_abs_build_var can just return
the shell variables instead of querying the build system.
2. Prune .git when we search for AndroidProduct.mks.
In internal source tree lunch time was reduced from ~15s to ~1.5s.
Bug: 27429759
(cherry picked from commit 08800fd905e70faf01d9392d00ff3f49d99097b7)
Change-Id: I862a0ec3c1aae97c552054dacec133e857042edf
diff --git a/core/product.mk b/core/product.mk
index 4d35704..7043cff 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -23,14 +23,21 @@
# and the .mk suffix) of the product makefile, "<product_name>:" can be
# omitted.
+# Search for AndroidProducts.mks in the given dir.
+# $(1): the path to the dir
+define _search-android-products-files-in-dir
+$(sort $(shell test -d $(1) && find -L $(1) \
+ -maxdepth 6 \
+ -name .git -prune \
+ -o -name AndroidProducts.mk -print))
+endef
+
#
# Returns the list of all AndroidProducts.mk files.
# $(call ) isn't necessary.
#
define _find-android-products-files
-$(sort $(shell test -d device && find -L device -maxdepth 6 -name AndroidProducts.mk)) \
- $(sort $(shell test -d vendor && find -L vendor -maxdepth 6 -name AndroidProducts.mk)) \
- $(sort $(shell test -d product && find -L product -maxdepth 6 -name AndroidProducts.mk)) \
+$(foreach d, device vendor product,$(call _search-android-products-files-in-dir,$(d))) \
$(SRC_TARGET_DIR)/product/AndroidProducts.mk
endef