Integrate Starlark-based configuration runner
If RBC_PRODUCT_CONFIG variable is set, obtain product configuration
variables by converting product configuration makefiles to Starlark
files and then executing them.
Also, introduce RBC_NO_PRODUCT_GRAPH variable to suppress product graph
generation. We cannot generate product graph with Starlark, so this
option allows to verify that the rest of the contents of the generated
Ninja files remains the same when Starlark-based converter is used.
This allows to perform the regression testing, i.e. running
`RBC_NO_PRODUCT_GRAPH=t DISABLE_ARTIFACT_PATH_REQUIREMENTS=t m nothing`
and
`RBC_PRODUCT_CONFIG=t m nothing`
should generate identical *.ninja files.
Bug: 181797530
Test: Manual
Change-Id: Ic6173a9640f32766b71c02a2b1833ce7a278e4cc
diff --git a/core/main.mk b/core/main.mk
index 8b75931..e0fb58d 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -1242,14 +1242,43 @@
# Name resolution for LOCAL_REQUIRED_MODULES:
# See the select-bitness-of-required-modules definition.
# $(1): product makefile
+
+# TODO(asmundak):
+# `product-installed-files` and `host-installed-files` macros below used to
+# call `get-product-var` directly to obtain per-file configuration variable
+# values (the value of variable FOO is fetched from PRODUCT.<product-makefile>.FOO).
+# Starlark-based configuration does not maintain per-file variable variable
+# values. To work around this problem, we utilize the fact that
+# `product-installed-files` and `host-installed-files` are called only in
+# two places:
+# 1. For the top-level product makefile (in this file). In this case
+# $(call get-product-var <product>, FOO) is the same as $(FOO) as the
+# product configuration has been run already. Therefore we define
+# _product-var macro to pick the values directly from product config
+# variables when using Starlark-based configuration.
+# 2. To check the path requirements (in artifact_path_requirements.mk).
+# Starlark-based configuration does not perform this check at the moment.
+# In the longer run most of the logic of this file will be moved to the
+# Starlark.
+
+ifndef RBC_PRODUCT_CONFIG
+define _product-var
+ $(call get-product-var,$(1),$(2))
+endef
+else
+define _product-var
+ $(call $(2))
+endef
+endif
+
define product-installed-files
$(eval _pif_modules := \
- $(call get-product-var,$(1),PRODUCT_PACKAGES) \
- $(if $(filter eng,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_ENG)) \
- $(if $(filter debug,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_DEBUG)) \
- $(if $(filter tests,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_TESTS)) \
- $(if $(filter asan,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_DEBUG_ASAN)) \
- $(if $(filter java_coverage,$(tags_to_install)),$(call get-product-var,$(1),PRODUCT_PACKAGES_DEBUG_JAVA_COVERAGE)) \
+ $(call _product-var,$(1),PRODUCT_PACKAGES) \
+ $(if $(filter eng,$(tags_to_install)),$(call _product-var,$(1),PRODUCT_PACKAGES_ENG)) \
+ $(if $(filter debug,$(tags_to_install)),$(call _product-var,$(1),PRODUCT_PACKAGES_DEBUG)) \
+ $(if $(filter tests,$(tags_to_install)),$(call _product-var,$(1),PRODUCT_PACKAGES_TESTS)) \
+ $(if $(filter asan,$(tags_to_install)),$(call _product-var,$(1),PRODUCT_PACKAGES_DEBUG_ASAN)) \
+ $(if $(filter java_coverage,$(tags_to_install)),$(call _product-var,$(1),PRODUCT_PACKAGES_DEBUG_JAVA_COVERAGE)) \
$(call auto-included-modules) \
) \
$(eval ### Filter out the overridden packages and executables before doing expansion) \
@@ -1260,13 +1289,13 @@
$(call expand-required-modules,_pif_modules,$(_pif_modules),$(_pif_overrides)) \
$(filter-out $(HOST_OUT_ROOT)/%,$(call module-installed-files, $(_pif_modules))) \
$(call resolve-product-relative-paths,\
- $(foreach cf,$(call get-product-var,$(1),PRODUCT_COPY_FILES),$(call word-colon,2,$(cf))))
+ $(foreach cf,$(call _product-var,$(1),PRODUCT_COPY_FILES),$(call word-colon,2,$(cf))))
endef
# Similar to product-installed-files above, but handles PRODUCT_HOST_PACKAGES instead
# This does support the :32 / :64 syntax, but does not support module overrides.
define host-installed-files
- $(eval _hif_modules := $(call get-product-var,$(1),PRODUCT_HOST_PACKAGES)) \
+ $(eval _hif_modules := $(call _product-var,$(1),PRODUCT_HOST_PACKAGES)) \
$(eval ### Split host vs host cross modules) \
$(eval _hcif_modules := $(filter host_cross_%,$(_hif_modules))) \
$(eval _hif_modules := $(filter-out host_cross_%,$(_hif_modules))) \
@@ -1351,7 +1380,7 @@
# Verify the artifact path requirements made by included products.
is_asan := $(if $(filter address,$(SANITIZE_TARGET)),true)
- ifneq (true,$(or $(is_asan),$(DISABLE_ARTIFACT_PATH_REQUIREMENTS)))
+ ifeq (,$(or $(is_asan),$(DISABLE_ARTIFACT_PATH_REQUIREMENTS),$(RBC_PRODUCT_CONFIG)))
include $(BUILD_SYSTEM)/artifact_path_requirements.mk
endif
else