Allow setting PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS to false
Some products clear PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS
in order to disable it. But oftentimes this clearing relies on
the fact that clearing a variable will also cause it to not
inherit from any already-inherited files. Starlark doesn't support
this inheritance behavior, so allow setting
PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS to false so that it
can be explicetly disabled instead of relying on the clearing
behavior.
Bug: 221312707
Test: Manually
Change-Id: I03a227911c6985a65fc5d210682bbd4ac9bd6747
diff --git a/core/artifact_path_requirements.mk b/core/artifact_path_requirements.mk
index ceaefa2..566b9f7 100644
--- a/core/artifact_path_requirements.mk
+++ b/core/artifact_path_requirements.mk
@@ -22,6 +22,10 @@
$(TARGET_OUT_SYSTEM_OTHER)/%.art
endif
+ifneq (,$(filter-out true false relaxed strict,$(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS))$(filter-out 1 0,$(words $(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS))))
+ $(error PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS must be one of [true, false, relaxed, strict], found: $(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS))
+endif
+
all_offending_files :=
$(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\
$(eval requirements := $(PRODUCTS.$(makefile).ARTIFACT_PATH_REQUIREMENTS)) \
@@ -46,7 +50,7 @@
$(eval allowed_patterns := $(call resolve-product-relative-paths,$(allowed))) \
$(eval offending_files := $(filter-out $(allowed_patterns),$(files_in_requirement))) \
$(eval enforcement := $(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS)) \
- $(if $(enforcement),\
+ $(if $(filter-out false,$(enforcement)),\
$(call maybe-print-list-and-error,$(offending_files),\
$(INTERNAL_PRODUCT) produces files inside $(makefile)s artifact path requirement. \
$(PRODUCT_ARTIFACT_PATH_REQUIREMENT_HINT)) \