diff --git a/core/main.mk b/core/main.mk index 0eb45fc2c0..7ca5503e06 100644 --- a/core/main.mk +++ b/core/main.mk @@ -929,6 +929,32 @@ define product-installed-files $(call module-installed-files, $(_pif_modules)) endef +# Fails the build if the given list is non-empty, and prints it entries (stripping PRODUCT_OUT). +# $(1): list of files to print +# $(2): heading to print on failure +define maybe-print-list-and-error +$(if $(strip $(1)), \ + $(warning $(2)) \ + $(info Offending entries:) \ + $(foreach e,$(sort $(1)),$(info $(patsubst $(PRODUCT_OUT)/%,%,$(e)))) \ + $(error Build failed) \ +) +endef + +ifeq (true|,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ENFORCE_PACKAGES_EXIST)|$(filter true,$(ALLOW_MISSING_DEPENDENCIES))) + _whitelist := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST) + _modules := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) + # Sanity check all modules in PRODUCT_PACKAGES exist. We check for the + # existence if either or the _32 variant. + _nonexistant_modules := $(filter-out $(ALL_MODULES),$(_modules)) + _nonexistant_modules := $(foreach m,$(_nonexistant_modules),\ + $(if $(call get-32-bit-modules,$(m)),,$(m))) + $(call maybe-print-list-and-error,$(filter-out $(_whitelist),$(_nonexistant_modules)),\ + $(INTERNAL_PRODUCT) includes non-existant modules in PRODUCT_PACKAGES) + $(call maybe-print-list-and-error,$(filter-out $(_nonexistant_modules),$(_whitelist)),\ + $(INTERNAL_PRODUCT) includes redundant whitelist entries for nonexistant PRODUCT_PACKAGES) +endif + ifdef FULL_BUILD product_FILES := $(call product-installed-files, $(INTERNAL_PRODUCT)) else @@ -948,18 +974,6 @@ define resolve-product-relative-paths $(foreach p,$(1),$(PRODUCT_OUT)/$(p)$(2)))) endef -# Fails the build if the given list is non-empty, and prints it entries (stripping PRODUCT_OUT). -# $(1): list of files to print -# $(2): heading to print on failure -define maybe-print-list-and-error -$(if $(strip $(1)), \ - $(warning $(2)) \ - $(info Offending entries:) \ - $(foreach e,$(sort $(1)),$(info $(patsubst $(PRODUCT_OUT)/%,%,$(e)))) \ - $(error Build failed) \ -) -endef - # Verify the artifact path requirements made by included products. $(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\ $(eval requirements := $(PRODUCTS.$(makefile).ARTIFACT_PATH_REQUIREMENTS)) \ diff --git a/core/product.mk b/core/product.mk index 375fb724e0..51b376a680 100644 --- a/core/product.mk +++ b/core/product.mk @@ -247,6 +247,16 @@ define require-artifacts-in-path $(sort $(ARTIFACT_PATH_REQUIREMENT_PRODUCTS) $(current_mk))) endef +# Makes including non-existant modules in PRODUCT_PACKAGES an error. +# $(1): whitelist of non-existant modules to allow. +define enforce-product-packages-exist + $(eval current_mk := $(strip $(word 1,$(_include_stack)))) \ + $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST := true) \ + $(eval PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST := $(1)) \ + $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST) \ + $(eval .KATI_READONLY := PRODUCTS.$(current_mk).PRODUCT_ENFORCE_PACKAGES_EXIST_WHITELIST) +endef + # # Do inherit-product only if $(1) exists # diff --git a/target/product/generic.mk b/target/product/generic.mk index dd0d663152..cc856f4f73 100644 --- a/target/product/generic.mk +++ b/target/product/generic.mk @@ -24,3 +24,8 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk) PRODUCT_BRAND := generic PRODUCT_DEVICE := generic PRODUCT_NAME := generic + +_whitelist := \ + device_manifest.xml \ + +$(call enforce-product-packages-exist,$(_whitelist))