From ec8316de2e95d63eb1c42adf88d3c033c2522f49 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 4 Apr 2022 11:52:52 -0700 Subject: [PATCH 1/2] Optionally dump RBC variables at the end of config.mk config.mk represents essentially the entire product/board configuration. In order to develop a "quick" rbc regression test, dump all the make variables at the end of config.mk. We can then compare these variable dumps instead of ninja files, because the ninja files take much longer to generate. Bug: 229132189 Test: Manually Change-Id: I4e8371be446b7e511aba22dff58530a6d9ff072f --- core/dumpvar.mk | 4 ++++ core/envsetup.mk | 22 ++++++++++++++-------- core/product_config.rbc | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/core/dumpvar.mk b/core/dumpvar.mk index 6b5c030e4d..6f3d14f20d 100644 --- a/core/dumpvar.mk +++ b/core/dumpvar.mk @@ -35,3 +35,7 @@ dump-many-vars : printf "'\n";) endif # CALLED_FROM_SETUP + +ifneq (,$(RBC_DUMP_CONFIG_FILE)) +$(call dump-variables-rbc,$(RBC_DUMP_CONFIG_FILE)) +endif diff --git a/core/envsetup.mk b/core/envsetup.mk index 049a4d6c8b..c32d380b0b 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -326,20 +326,26 @@ endif # raw ones. define dump-variables-rbc $(eval _dump_variables_rbc_excluded := \ + BOARD_PLAT_PRIVATE_SEPOLICY_DIR \ + BOARD_PLAT_PUBLIC_SEPOLICY_DIR \ + BUILD_NUMBER \ + DATE \ LOCAL_PATH \ + MAKEFILE_LIST \ + PRODUCTS \ + PRODUCT_COPY_OUT_% \ + RBC_PRODUCT_CONFIG \ + RBC_BOARD_CONFIG \ + SOONG_% \ TOPDIR \ TRACE_BEGIN_SOONG \ - BOARD_PLAT_PUBLIC_SEPOLICY_DIR \ - BOARD_PLAT_PRIVATE_SEPOLICY_DIR \ - USER \ - SOONG_% \ - PRODUCT_COPY_OUT_%)\ -$(file >$(OUT_DIR)/dump-variables-rbc-temp.txt,$(subst $(space),$(newline),$(filter-out $(_dump_variables_rbc_excluded),$(.VARIABLES)))) + USER) +$(file >$(OUT_DIR)/dump-variables-rbc-temp.txt,$(subst $(space),$(newline),$(sort $(filter-out $(_dump_variables_rbc_excluded),$(.VARIABLES))))) $(file >$(1),\ $(foreach v, $(shell grep -he "^[A-Z][A-Z0-9_]*$$" $(OUT_DIR)/dump-variables-rbc-temp.txt),\ $(v) := $(strip $($(v)))$(newline))\ -$(foreach ns,$(SOONG_CONFIG_NAMESPACES),\ -$(foreach v,$(SOONG_CONFIG_$(ns)),\ +$(foreach ns,$(sort $(SOONG_CONFIG_NAMESPACES)),\ +$(foreach v,$(sort $(SOONG_CONFIG_$(ns))),\ $$(call soong_config_set,$(ns),$(v),$(SOONG_CONFIG_$(ns)_$(v)))$(newline)))) endef diff --git a/core/product_config.rbc b/core/product_config.rbc index 11064f33b9..8a83a93af5 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -162,7 +162,7 @@ def _product_configuration(top_pcm_name, top_pcm, input_variables_init): globals["PRODUCTS."+name+".mk.ARTIFACT_PATH_ALLOWED_LIST"] = handle.artifact_path_allowed_list globals["PRODUCTS."+name+".mk.ARTIFACT_PATH_REQUIREMENT_IS_RELAXED"] = "true" if handle.artifact_path_requirement_is_relaxed[0] else "" globals.setdefault("ARTIFACT_PATH_REQUIREMENT_PRODUCTS", []) - globals["ARTIFACT_PATH_REQUIREMENT_PRODUCTS"] += [name+".mk"] + globals["ARTIFACT_PATH_REQUIREMENT_PRODUCTS"] = sorted(globals["ARTIFACT_PATH_REQUIREMENT_PRODUCTS"] + [name+".mk"]) # Now we know everything about this PCM, record it in 'configs'. children = handle.inherited_modules From e050e8fec0916942246a68b7248a917c54a96c36 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Wed, 13 Apr 2022 13:52:14 -0700 Subject: [PATCH 2/2] Implement enforce_product_packages_exist This is something that didn't show up as a regression when testing ninja files, but does show up when testing make variables. Bug: 229132189 Test: New --quick mode in rbc_dashboard.py Change-Id: I6c1219cdc5ee1d8b3cc39e8f944e99fc380d4668 --- core/product_config.rbc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/product_config.rbc b/core/product_config.rbc index 8a83a93af5..b861cb9009 100644 --- a/core/product_config.rbc +++ b/core/product_config.rbc @@ -164,6 +164,10 @@ def _product_configuration(top_pcm_name, top_pcm, input_variables_init): globals.setdefault("ARTIFACT_PATH_REQUIREMENT_PRODUCTS", []) globals["ARTIFACT_PATH_REQUIREMENT_PRODUCTS"] = sorted(globals["ARTIFACT_PATH_REQUIREMENT_PRODUCTS"] + [name+".mk"]) + if handle.product_enforce_packages_exist[0]: + globals["PRODUCTS."+name+".mk.PRODUCT_ENFORCE_PACKAGES_EXIST"] = "true" + globals["PRODUCTS."+name+".mk.PRODUCT_ENFORCE_PACKAGES_EXIST_ALLOW_LIST"] = handle.product_enforce_packages_exist_allow_list + # Now we know everything about this PCM, record it in 'configs'. children = handle.inherited_modules if _options.trace_modules: @@ -434,6 +438,8 @@ def __h_new(): artifact_path_requirements = list(), artifact_path_allowed_list = list(), artifact_path_requirement_is_relaxed = [False], # as a list so that we can reassign it + product_enforce_packages_exist = [False], + product_enforce_packages_exist_allow_list = [], ) def __h_cfg(handle): @@ -498,11 +504,11 @@ def _copy_if_exists(path_pair): # Check that l[0] exists return [":".join(value)] if rblf_file_exists(value[0]) else [] -def _enforce_product_packages_exist(pkg_string_or_list): +def _enforce_product_packages_exist(handle, pkg_string_or_list=[]): """Makes including non-existent modules in PRODUCT_PACKAGES an error.""" - - #TODO(asmundak) - pass + handle.product_enforce_packages_exist[0] = True + handle.product_enforce_packages_exist_allow_list.clear() + handle.product_enforce_packages_exist_allow_list.extend(__words(pkg_string_or_list)) def _add_product_dex_preopt_module_config(handle, modules, config): """Equivalent to add-product-dex-preopt-module-config from build/make/core/product.mk."""