Add PRODUCT_IGNORE_ALL_ANDROIDMK to ignore Android.mk files
PRODUCT_ALLOWED_ANDROIDMK_FILES can be used for products that still have some Android.mk files that need to be included.
PRODUCT_ANDROIDMK_ALLOWLIST_FILE can be used to allowlist Android.mk files that are not in AOSP.
Bug: 318428689
Test: lunch aosp_cf_x86_64_phone-trunk_staging-eng && m
Test: CIs
Change-Id: Ie64040608c795a949e3d7af45f176209c6d01d9a
diff --git a/core/main.mk b/core/main.mk
index 5142adc..83d42af 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -281,7 +281,17 @@
# Android.mk files are only used on Linux builds, Mac only supports Android.bp
ifeq ($(HOST_OS),linux)
- subdir_makefiles += $(file <$(OUT_DIR)/.module_paths/Android.mk.list)
+ ifeq ($(PRODUCT_IGNORE_ALL_ANDROIDMK),true)
+ allowed_androidmk_files :=
+ ifdef PRODUCT_ANDROIDMK_ALLOWLIST_FILE
+ -include $(PRODUCT_ANDROIDMK_ALLOWLIST_FILE)
+ endif
+ allowed_androidmk_files += $(PRODUCT_ALLOWED_ANDROIDMK_FILES)
+ subdir_makefiles += $(filter $(allowed_androidmk_files),$(file <$(OUT_DIR)/.module_paths/Android.mk.list))
+ allowed_androidmk_files :=
+ else
+ subdir_makefiles += $(file <$(OUT_DIR)/.module_paths/Android.mk.list)
+ endif
endif
subdir_makefiles += $(SOONG_OUT_DIR)/late-$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).mk
diff --git a/core/product.mk b/core/product.mk
index 7cf4ec2..9c567c3 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -492,6 +492,13 @@
# should be included in the system_linker_config.
_product_list_vars += PRODUCT_EXTRA_STUB_LIBRARIES
+# If set to true, all Android.mk files will be ignored.
+_product_single_value_vars += PRODUCT_IGNORE_ALL_ANDROIDMK
+# When PRODUCT_IGNORE_ALL_ANDROIDMK is set to true, this variable will be used to allow some Android.mk files.
+_product_list_vars += PRODUCT_ALLOWED_ANDROIDMK_FILES
+# When PRODUCT_IGNORE_ALL_ANDROIDMK is set to true, path of file that contains a list of allowed Android.mk files
+_product_single_value_vars += PRODUCT_ANDROIDMK_ALLOWLIST_FILE
+
.KATI_READONLY := _product_single_value_vars _product_list_vars
_product_var_list :=$= $(_product_single_value_vars) $(_product_list_vars)