Allow more relaxed artifact path req enforcement
Only enforce whitelist entries are unused if the enforcement variable
is set to "true" or "strict". If set to something else (e.g. "relaxed"),
allow redundant whitelist entries.
This also enables adding wildcard entries, which were previously
considered unused.
Test: downstream
Bug: 117637311
Bug: 80410283
Change-Id: I67a84f8ecfad5fa68c21ee728f1e3085ef89fbcf
diff --git a/core/main.mk b/core/main.mk
index 7f673e9..4b24acc 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1034,9 +1034,11 @@
$(eval whitelist := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST)) \
$(eval whitelist_patterns := $(call resolve-product-relative-paths,$(whitelist))) \
$(eval offending_files := $(filter-out $(whitelist_patterns),$(files_in_requirement))) \
- $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS),\
+ $(eval enforcement := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS)) \
+ $(if $(enforcement),\
$(call maybe-print-list-and-error,$(offending_files),$(INTERNAL_PRODUCT) produces files inside $(makefile)s artifact path requirement.) \
- $(eval unused_whitelist := $(filter-out $(extra_files),$(whitelist_patterns))) \
+ $(eval unused_whitelist := $(if $(filter true strict,$(enforcement)),\
+ $(foreach p,$(whitelist_patterns),$(if $(filter $(p),$(extra_files)),,$(p))))) \
$(call maybe-print-list-and-error,$(unused_whitelist),$(INTERNAL_PRODUCT) includes redundant artifact path requirement whitelist entries.) \
) \
)