From 000e89a5b95a1d3071277ff279263204f49cbd78 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 30 Apr 2012 15:48:27 -0700 Subject: [PATCH] Strengthen dependencies on LOCAL_REQUIRED_MODULES Bug: 6418863 This change expands the PRODUCT_PACKAGES with the required modules. Before this change, since the required modules are not in the PRODUCT_PACKAGES, they are not directly depended on by the image files. If the dependent is not to be included in the image but the required modules are to be included, the dependency of the image on the required modules gets lost! That would lead to build race condition. Change-Id: I0b656db1538ca43d3785dbf17364ffa88b80ac41 --- core/definitions.mk | 13 +++++++++++++ core/main.mk | 10 +++------- core/tasks/vendor_module_check.mk | 22 +++++----------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/core/definitions.mk b/core/definitions.mk index 9943d5ff85..f82bfa59cb 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1999,6 +1999,19 @@ define set-inherited-package-variables-internal ,) endef +########################################################### +## Expand a module name list with REQUIRED modules +########################################################### +# $(1): The variable name that holds the initial module name list. +# the variable will be modified to hold the expanded results. +# $(2): The initial module name list. +# Returns empty string (maybe with some whitespaces). +define expand-required-modules +$(eval _erm_new_modules := $(sort $(filter-out $($(1)),\ + $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED)))))\ +$(if $(_erm_new_modules),$(eval $(1) += $(_erm_new_modules))\ + $(call expand-required-modules,$(1),$(_erm_new_modules))) +endef ########################################################### ## Other includes diff --git a/core/main.mk b/core/main.mk index c22c967618..fa56b83920 100644 --- a/core/main.mk +++ b/core/main.mk @@ -546,13 +546,9 @@ ifdef FULL_BUILD # The base list of modules to build for this product is specified # by the appropriate product definition file, which was included # by product_config.make. - user_PACKAGES := $(call module-installed-files, \ - $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)) - ifeq (0,1) - $(info user packages for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):) - $(foreach p,$(user_PACKAGES),$(info : $(p))) - $(error done) - endif + user_PACKAGES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) + $(call expand-required-modules,user_PACKAGES,$(user_PACKAGES)) + user_PACKAGES := $(call module-installed-files, $(user_PACKAGES)) else # We're not doing a full build, and are probably only including # a subset of the module makefiles. Don't try to build any modules diff --git a/core/tasks/vendor_module_check.mk b/core/tasks/vendor_module_check.mk index 65c4258d66..d26a0453a9 100644 --- a/core/tasks/vendor_module_check.mk +++ b/core/tasks/vendor_module_check.mk @@ -30,21 +30,8 @@ _vendor_owner_whitelist := \ ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)) -_check_modules := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)) - -# expand with the required modules -# $(1) the module name set to expand -define _expand_required_modules -$(eval _erm_new_modules:=)\ -$(foreach m, $(1), $(eval r:=$(ALL_MODULES.$(m).REQUIRED))\ - $(if $(r), $(if $(filter $(_check_modules), $(r)),,\ - $(eval _check_modules := $(_check_modules) $(r))\ - $(eval _erm_new_modules := $(_erm_new_modules) $(r)))))\ -$(if $(_erm_new_modules), $(call _expand_required_modules, $(_erm_new_modules))) -endef - -$(call _expand_required_modules, $(_check_modules)) - +_vendor_check_modules := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)) +$(call expand-required-modules,_vendor_check_modules,$(_vendor_check_modules)) # Restrict owners ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))) @@ -58,7 +45,7 @@ $(error Error: Product "$(TARGET_PRODUCT)" can not have PRODUCT_COPY_FILES from $(filter vendor/%, $(PRODUCT_COPY_FILES))) endif -$(foreach m, $(_check_modules), \ +$(foreach m, $(_vendor_check_modules), \ $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\ $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \ @@ -70,7 +57,7 @@ endif # Restrict paths ifneq (,$(filter path all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))) -$(foreach m, $(_check_modules), \ +$(foreach m, $(_vendor_check_modules), \ $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\ $(if $(filter $(TARGET_OUT_VENDOR)/%, $(ALL_MODULES.$(m).INSTALLED)),,\ $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \ @@ -79,4 +66,5 @@ $(foreach m, $(_check_modules), \ endif +_vendor_check_modules := endif