[PATCH v1 4/5] Makefile: make dependencies on validated configurations explicit


Junjie Mao
 

ACRN config tools generate source files, scripts and binaries based on
users' inputs in the configurations files, i.e., board and scenario
XMLs. Those generation activities all assume that users' inputs are
properly validated, so that all assumptions they have on such inputs are
hold.

Unfortunately, not all dependencies on validated user inputs are explicitly
stated in the Makefiles today. That will cause random error messages
(typically a Python stack trace) to be printed along with validation errors
when an invalid scenario XML is given, and such messages confuse users
about the root causes of the failure.

This patch decouples scenario validation from genconf.sh and make that step
as a separate target that depends on the board and scenario XMLs. One
timestamp file is generated only when the validation succeeds so that
targets requiring validated XMLs can refer that file in its dependency list
to make it explicit.

Dependencies of the following targets are also updated accordingly:

* $(HV_ALLOCATION_XML), which is the allocation XML including static
allocation results, now also depends on validated XMLs.

* $(HV_CONFIG_TIMESTAMP), which records when the config source files are
generated, now also depends on validated XMLs.

* $(SERIAL_CONF), which is the serial conf for the service VM, depends on
the allocation XML.

By the way, the missing dependency on HV_CONFIG_DIR for touching
HV_DIFFCONFIG_LIST is added to fix the "file not found" issue.

Signed-off-by: Junjie Mao <junjie.mao@...>
---
hypervisor/Makefile | 2 +-
hypervisor/scripts/genconf.sh | 7 +++----
hypervisor/scripts/makefile/config.mk | 14 ++++++++++----
3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/hypervisor/Makefile b/hypervisor/Makefile
index 3bd65a2d8..9c7da5bba 100644
--- a/hypervisor/Makefile
+++ b/hypervisor/Makefile
@@ -433,7 +433,7 @@ $(HV_ACPI_TABLE_TIMESTAMP): $(HV_CONFIG_TIMESTAMP)
python3 ../misc/config_tools/acpi_gen/bin_gen.py --board $(HV_BOARD_XML) --scenario $(HV_SCENARIO_XML) --asl $(HV_CONFIG_DIR) --out $(HV_OBJDIR) --iasl_path $(ASL_COMPILER) --iasl_min_ver $(IASL_MIN_VER)
@touch $(HV_ACPI_TABLE_TIMESTAMP)

-$(SERIAL_CONF): $(HV_CONFIG_TIMESTAMP)
+$(SERIAL_CONF): $(HV_CONFIG_TIMESTAMP) $(HV_ALLOCATION_XML)
@echo "generate the serial configuration file for service VM ..."
python3 ../misc/config_tools/service_vm_config/serial_config.py --allocation $(HV_ALLOCATION_XML) --scenario $(HV_SCENARIO_XML) --out $(SERIAL_CONF)

diff --git a/hypervisor/scripts/genconf.sh b/hypervisor/scripts/genconf.sh
index dfdd7a222..c9efbcc93 100644
--- a/hypervisor/scripts/genconf.sh
+++ b/hypervisor/scripts/genconf.sh
@@ -22,12 +22,11 @@ apply_patch () {
tool_dir=${base_dir}/../misc/config_tools
diffconfig_list=${out}/.diffconfig

-python3 ${tool_dir}/scenario_config/validator.py ${board_xml} ${scenario_xml} &&
python3 ${tool_dir}/board_config/board_cfg_gen.py --board ${board_xml} --scenario ${scenario_xml} --out ${out} &&
python3 ${tool_dir}/acpi_gen/asl_gen.py --board ${board_xml} --scenario ${scenario_xml} --out ${out}
-
-if [ $? -ne 0 ]; then
- exit $?
+exitcode=$?
+if [ $exitcode -ne 0 ]; then
+ exit $exitcode
fi

if ! which xsltproc ; then
diff --git a/hypervisor/scripts/makefile/config.mk b/hypervisor/scripts/makefile/config.mk
index 26854e464..4051e7bd2 100644
--- a/hypervisor/scripts/makefile/config.mk
+++ b/hypervisor/scripts/makefile/config.mk
@@ -127,7 +127,8 @@ HV_ALLOCATION_XML := $(HV_CONFIG_DIR)/allocation.xml
HV_UNIFIED_XML := $(HV_CONFIG_DIR)/unified.xml
HV_CONFIG_H := $(HV_OBJDIR)/include/config.h
HV_CONFIG_MK := $(HV_CONFIG_DIR)/config.mk
-HV_CONFIG_TIMESTAMP := $(HV_CONFIG_DIR)/.timestamp
+HV_VALIDATION_TIMESTAMP := $(HV_CONFIG_DIR)/.validation.timestamp
+HV_CONFIG_TIMESTAMP := $(HV_CONFIG_DIR)/.configfiles.timestamp
HV_DIFFCONFIG_LIST := $(HV_CONFIG_DIR)/.diffconfig

# Directory containing generated configuration sources for diffconfig
@@ -219,7 +220,7 @@ $(HV_SCENARIO_XML):

# A unified XML is generated to include board and scenario XML files so that XSLT scripts have access to both for
# generating source files.
-$(HV_ALLOCATION_XML): $(HV_BOARD_XML) $(HV_SCENARIO_XML) | $(HV_CONFIG_DIR)
+$(HV_ALLOCATION_XML): $(HV_BOARD_XML) $(HV_SCENARIO_XML) $(HV_VALIDATION_TIMESTAMP) | $(HV_CONFIG_DIR)
@python3 $(HV_CONFIG_TOOL_DIR)/static_allocators/main.py --board $(HV_BOARD_XML) --scenario $(HV_SCENARIO_XML) --output $(HV_ALLOCATION_XML)
@echo "$@ generated"

@@ -238,7 +239,12 @@ $(HV_CONFIG_H): $(HV_UNIFIED_XML)
@xsltproc -o $@ --xinclude --xincludestyle $(HV_CONFIG_XFORM_DIR)/config.h.xsl $<
@echo "$@ generated"

-$(HV_CONFIG_TIMESTAMP): $(HV_UNIFIED_XML) ${HV_DIFFCONFIG_LIST} | $(HV_CONFIG_DIR)
+$(HV_VALIDATION_TIMESTAMP): $(HV_BOARD_XML) $(HV_SCENARIO_XML)
+ @echo "Validating scenario configurations..."
+ @python3 $(HV_CONFIG_TOOL_DIR)/scenario_config/validator.py $(HV_BOARD_XML) $(HV_SCENARIO_XML)
+ @touch $@
+
+$(HV_CONFIG_TIMESTAMP): $(HV_VALIDATION_TIMESTAMP) $(HV_UNIFIED_XML) ${HV_DIFFCONFIG_LIST} | $(HV_CONFIG_DIR)
@sh $(BASEDIR)/scripts/genconf.sh $(BASEDIR) $(HV_BOARD_XML) $(HV_SCENARIO_XML) $(HV_CONFIG_DIR) $(HV_UNIFIED_XML)
@touch $@

@@ -287,7 +293,7 @@ else
endif
endif

-$(HV_DIFFCONFIG_LIST):
+$(HV_DIFFCONFIG_LIST): | $(HV_CONFIG_DIR)
@touch $@

menuconfig:
--
2.30.2