summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2012-09-27 13:26:25 -0700
committerYing Wang <wangying@google.com>2012-09-28 15:08:12 -0700
commit54fa8c3ff9b1f0f1b0b9c551be864f1b7378c7fc (patch)
tree324f000cc94c926895668eac76ff5fa526771e01 /core
parentf7592d987d38d434a4ad1f43607a2151dad2cd4f (diff)
downloadbuild-54fa8c3ff9b1f0f1b0b9c551be864f1b7378c7fc.tar.gz
build-54fa8c3ff9b1f0f1b0b9c551be864f1b7378c7fc.tar.bz2
build-54fa8c3ff9b1f0f1b0b9c551be864f1b7378c7fc.zip
Load only the current product config makefile.
To reduce the start time. With the change and previous change of doing clean step in only given paths, start time of mm/mmm is reduced from ~5s to about 1s; lunch time is reduced from ~40s to 3.5s. Bug: 7186768,7169854 Change-Id: Ifd72ba1c6362a5e1125a23c505fd47947ab56675
Diffstat (limited to 'core')
-rw-r--r--core/base_rules.mk3
-rw-r--r--core/config.mk5
-rw-r--r--core/definitions.mk4
-rw-r--r--core/droiddoc.mk2
-rw-r--r--core/node_fns.mk2
-rw-r--r--core/product.mk7
-rw-r--r--core/product_config.mk70
7 files changed, 64 insertions, 29 deletions
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 808b95202..2957cec9c 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -50,9 +50,6 @@ endif
#$(shell rm -f tag-list.csv)
#tag-list-first-time := false
#endif
-#comma := ,
-#empty :=
-#space := $(empty) $(empty)
#$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(LOCAL_MODULE_TAGS))) >> tag-list.csv)
LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
diff --git a/core/config.mk b/core/config.mk
index e1f49af90..747d8edcb 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -14,6 +14,11 @@ else
SHELL := /bin/bash
endif
+# Utility variables.
+empty :=
+space := $(empty) $(empty)
+comma := ,
+
# Tell python not to spam the source tree with .pyc files. This
# only has an effect on python 2.6 and above.
export PYTHONDONTWRITEBYTECODE := 1
diff --git a/core/definitions.mk b/core/definitions.mk
index 13af6fc35..12dce3dfe 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -574,10 +574,6 @@ endef
###########################################################
## Convert "a b c" into "a:b:c"
###########################################################
-
-empty :=
-space := $(empty) $(empty)
-
define normalize-path-list
$(subst $(space),:,$(strip $(1)))
endef
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
index e31296541..9f429336c 100644
--- a/core/droiddoc.mk
+++ b/core/droiddoc.mk
@@ -85,8 +85,6 @@ full_java_libs += $(addprefix $(LOCAL_PATH)/,$(LOCAL_STATIC_JAVA_LIBRARIES)) $(L
full_java_lib_deps += $(addprefix $(LOCAL_PATH)/,$(LOCAL_STATIC_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
endif
-empty :=
-space := $(empty) $(empty)
$(full_target): PRIVATE_CLASSPATH := $(subst $(space),:,$(full_java_libs))
endif # !LOCAL_IS_HOST_MODULE
diff --git a/core/node_fns.mk b/core/node_fns.mk
index 40abff765..ccfcc2518 100644
--- a/core/node_fns.mk
+++ b/core/node_fns.mk
@@ -94,8 +94,6 @@ endef
# - Replace "|||" with spaces, breaking haystack back into
# individual words.
#
-empty :=
-space := $(empty) $(empty)
define uniq-word
$(strip \
$(if $(filter-out 0 1,$(words $(filter $(2),$(1)))), \
diff --git a/core/product.mk b/core/product.mk
index c0e6e3efc..b934826ad 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -16,7 +16,12 @@
#
# Functions for including AndroidProducts.mk files
-#
+# PRODUCT_MAKEFILES is set up in AndroidProducts.mks.
+# Format of PRODUCT_MAKEFILES:
+# <product_name>:<path_to_the_product_makefile>
+# If the <product_name> is the same as the base file name (without dir
+# and the .mk suffix) of the product makefile, "<product_name>:" can be
+# omitted.
#
# Returns the list of all AndroidProducts.mk files.
diff --git a/core/product_config.mk b/core/product_config.mk
index 7bb18527c..e05907d29 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -181,17 +181,54 @@ include $(BUILD_SYSTEM)/product.mk
include $(BUILD_SYSTEM)/device.mk
ifneq ($(strip $(TARGET_BUILD_APPS)),)
- # An unbundled app build needs only the core product makefiles.
- $(call import-products,$(call get-product-makefiles,\
- $(SRC_TARGET_DIR)/product/AndroidProducts.mk))
+# An unbundled app build needs only the core product makefiles.
+all_product_configs := $(call get-product-makefiles,\
+ $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
else
- # Read in all of the product definitions specified by the AndroidProducts.mk
- # files in the tree.
- #
- #TODO: when we start allowing direct pointers to product files,
- # guarantee that they're in this list.
- $(call import-products, $(get-all-product-makefiles))
-endif # TARGET_BUILD_APPS
+# Read in all of the product definitions specified by the AndroidProducts.mk
+# files in the tree.
+all_product_configs := $(get-all-product-makefiles)
+endif
+
+# Find the product config makefile for the current product.
+# all_product_configs consists items like:
+# <product_name>:<path_to_the_product_makefile>
+# or just <path_to_the_product_makefile> in case the product name is the
+# same as the base filename of the product config makefile.
+current_product_makefile :=
+all_product_makefiles :=
+$(foreach f, $(all_product_configs),\
+ $(eval _cpm_words := $(subst :,$(space),$(f)))\
+ $(eval _cpm_word1 := $(word 1,$(_cpm_words)))\
+ $(eval _cpm_word2 := $(word 2,$(_cpm_words)))\
+ $(if $(_cpm_word2),\
+ $(eval all_product_makefiles += $(_cpm_word2))\
+ $(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
+ $(eval current_product_makefile += $(_cpm_word2)),),\
+ $(eval all_product_makefiles += $(f))\
+ $(if $(filter $(TARGET_PRODUCT),$(basename $(notdir $(f)))),\
+ $(eval current_product_makefile += $(f)),)))
+_cpm_words :=
+_cpm_word1 :=
+_cpm_word2 :=
+current_product_makefile := $(strip $(current_product_makefile))
+all_product_makefiles := $(strip $(all_product_makefiles))
+
+ifneq (,$(filter product-graph dump-products, $(MAKECMDGOALS)))
+# Import all product makefiles.
+$(call import-products, $(all_product_makefiles))
+else
+# Import just the current product.
+ifndef current_product_makefile
+$(error Can not locate config makefile for product "$(TARGET_PRODUCT)")
+endif
+ifneq (1,$(words $(current_product_makefile)))
+$(error Product "$(TARGET_PRODUCT)" ambiguous: matches $(current_product_makefile))
+endif
+$(call import-products, $(current_product_makefile))
+endif # Import all or just the current product makefile
+
+# Sanity check
$(check-all-products)
ifneq ($(filter dump-products, $(MAKECMDGOALS)),)
@@ -199,17 +236,16 @@ $(dump-products)
$(error done)
endif
-ifeq (a,b)
-$(info PRODUCTS -----------)
-$(foreach product, $(PRODUCTS), $(info $(PRODUCTS.$(product).PRODUCT_NAME)))# $(product)))
-$(error stop)
-endif
-
# Convert a short name like "sooner" into the path to the product
# file defining that product.
#
INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))
-#$(error TARGET_PRODUCT $(TARGET_PRODUCT) --> $(INTERNAL_PRODUCT))
+ifneq ($(current_product_makefile),$(INTERNAL_PRODUCT))
+$(error PRODUCT_NAME inconsistent in $(current_product_makefile) and $(INTERNAL_PRODUCT))
+endif
+current_product_makefile :=
+all_product_makefiles :=
+all_product_configs :=
# Find the device that this product maps to.
TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)