config_tools: populate default values in scenario XML

While we have default values of configuration entries stated in the schema
of scenario XMLs, today we still require user-given scenario XMLs to
contain literally ALL XML nodes. Missing of a single node will cause schema
validation errors even though we can use its default value defined in the
schema.

This patch allows user-given scenario XMLs to ignore nodes with default
values. It is done by adding the missing nodes, all containing the defined
default values, to the input scenario XML when copying it to the build
directory. This approach imposes no changes to either the schema or
subsequent scripts in the build system.

Tracked-On: #6292
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao
2021-08-31 13:39:32 +08:00
committed by wenlingz
parent 955103f7ea
commit 2bfaa34cf2
2 changed files with 97 additions and 1 deletions

View File

@@ -113,6 +113,7 @@ HV_UNIFIED_XML_IN := $(BASEDIR)/scripts/makefile/unified.xml.in
HV_PREDEFINED_DATA_DIR := $(realpath $(BASEDIR)/../misc/config_tools/data)
HV_CONFIG_TOOL_DIR := $(realpath $(BASEDIR)/../misc/config_tools)
HV_CONFIG_XFORM_DIR := $(HV_CONFIG_TOOL_DIR)/xforms
HV_SCENARIO_XSD := $(HV_CONFIG_TOOL_DIR)/schema/config.xsd
# Paths to the outputs:
HV_CONFIG_DIR := $(HV_OBJDIR)/configs
@@ -208,7 +209,7 @@ $(HV_SCENARIO_XML):
if [ -f $(SCENARIO_FILE) ]; then \
echo "Scneario XML is configuration fetched from $(realpath $(SCENARIO_FILE))"; \
mkdir -p $(dir $(HV_SCENARIO_XML)); \
cp $(SCENARIO_FILE) $(HV_SCENARIO_XML); \
python3 $(HV_CONFIG_TOOL_DIR)/scenario_config/default_populator.py $(HV_SCENARIO_XSD) $(SCENARIO_FILE) $(HV_SCENARIO_XML); \
else \
echo "No pre-defined scenario available at $(SCENARIO_FILE)"; \
echo "Try setting another predefined BOARD or SCENARIO or specifying a scenario XML file"; \