From e113fb1d41664add7618d6ce4abafdfff3e027fb Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Wed, 26 Sep 2012 16:00:54 -0700 Subject: [PATCH 1/3] Run clean steps in only given paths when using mm/mmm To speed up mm/mmm start time. At the same time, we should copy over the other clean steps. (cherry-pick of 6ea58cb3dc564ce112b28f1a7c6936317168d931.) Bug: 7186768 Change-Id: I158b0d7e4ecaa773ec3a336cd326e27ee8c26a88 --- core/cleanbuild.mk | 4 ++++ core/cleanspec.mk | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk index e6db5cbb3..1b662b982 100644 --- a/core/cleanbuild.mk +++ b/core/cleanbuild.mk @@ -78,6 +78,10 @@ else $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \ $(shell $(INTERNAL_CLEAN_STEP.$(step))) \ ) + # If we are running mm/mmm, we should copy over the other clean steps too. + ifneq ($(ONE_SHOT_MAKEFILE),) + INTERNAL_CLEAN_STEPS := $(strip $(CURRENT_CLEAN_STEPS) $(steps)) + endif steps := endif CURRENT_CLEAN_BUILD_VERSION := diff --git a/core/cleanspec.mk b/core/cleanspec.mk index d4a8eed27..a3eb7cd1a 100644 --- a/core/cleanspec.mk +++ b/core/cleanspec.mk @@ -63,7 +63,13 @@ INTERNAL_CLEAN_BUILD_VERSION := 6 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ +ifneq ($(ONE_SHOT_MAKEFILE),) +cs_subdirs := $(dir $(ONE_SHOT_MAKEFILE)) +else +cs_subdirs := . +endif subdir_cleanspecs := \ - $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git . CleanSpec.mk) + $(shell build/tools/findleaves.py --prune=out --prune=.repo --prune=.git $(cs_subdirs) CleanSpec.mk) include $(subdir_cleanspecs) +cs_subdirs := subdir_cleanspecs := From 0c4eb4188553fc06049834111416067da53ac605 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Thu, 27 Sep 2012 13:26:25 -0700 Subject: [PATCH 2/3] 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. (cherry-pick of 157a5e1695593f935c3223430f4530e21f990378.) Bug: 7186768,7169854 Change-Id: I0be5e2721efa66a80f112acf8f95e177ebc2f65b --- core/base_rules.mk | 3 -- core/config.mk | 5 +++ core/definitions.mk | 4 -- core/droiddoc.mk | 2 - core/node_fns.mk | 2 - core/product.mk | 7 +++- core/product_config.mk | 70 +++++++++++++++++++++++-------- target/product/AndroidProducts.mk | 6 +++ 8 files changed, 70 insertions(+), 29 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index deb73eab6..6724c2205 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 03e424590..a8944449c 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 9d55197e2..d5c83d55c 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 d9e418603..81042a11a 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: +# : +# If the is the same as the base file name (without dir +# and the .mk suffix) of the product makefile, ":" can be +# omitted. # # Returns the list of all AndroidProducts.mk files. diff --git a/core/product_config.mk b/core/product_config.mk index 9c85d2c51..de1c86316 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: +# : +# or just 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) diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk index 92796339a..e8ce9df86 100644 --- a/target/product/AndroidProducts.mk +++ b/target/product/AndroidProducts.mk @@ -18,6 +18,12 @@ # This file should set PRODUCT_MAKEFILES to a list of product makefiles # to expose to the build system. LOCAL_DIR will already be set to # the directory containing this file. +# PRODUCT_MAKEFILES is set up in AndroidProducts.mks. +# Format of PRODUCT_MAKEFILES: +# : +# If the is the same as the base file name (without dir +# and the .mk suffix) of the product makefile, ":" can be +# omitted. # # This file may not rely on the value of any variable other than # LOCAL_DIR; do not use any conditionals, and do not look up the From e37c3dc3f6c46d15113f0e8e4df28e47646995b9 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Thu, 27 Sep 2012 17:42:04 -0700 Subject: [PATCH 3/3] Build only modules required by the current product. Don't build modules_to_check by default. Instead add "checkbuild" to the command line as a build goal, if you want to build everything. We can use the "checkbuild" goal to make sure some build targets on the build server still build everything. (cherry-pick of 5a88269ad6ed44fb163f96847954faac21292567.) Bug: 7253452 Change-Id: I21eb93f3cb430c9531fe41a2f5d7b445c09938b9 --- core/main.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/core/main.mk b/core/main.mk index 7bd55b8ce..77f9fc510 100644 --- a/core/main.mk +++ b/core/main.mk @@ -710,7 +710,6 @@ $(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers .PHONY: files files: prebuilt \ $(modules_to_install) \ - $(modules_to_check) \ $(INSTALLED_ANDROID_INFO_TXT_TARGET) # -------------------------------------------------------------------