config_tools: unify the CLI of scenario-manipulating scripts

Today the scripts that populate default values and validate scenarios have
different command-line interfaces: the former requires an XML schema as
input (which is cumbersome in most cases), while the latter always infer
where the XML schema is (which is inflexible).

This patch unifies the command line options of those scripts as follows:

  - The scenario XML is always a required positional argument.

  - The output file path (if any) is an optional positional argument.

  - The schema XML file is an optional long option. When not specified, the
    scripts will always use the one under the misc/config_tools/schema
    directory.

Also, this patch makes the validator.py executable, as is done to other
executable scripts in the repo.

Tracked-On: #6690
Signed-off-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
Junjie Mao
2022-03-03 19:38:50 +08:00
committed by acrnsi-robot
parent 0a7910c7f0
commit 433b37b1a8
3 changed files with 10 additions and 8 deletions

View File

@@ -111,7 +111,6 @@ 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
@@ -200,7 +199,7 @@ $(HV_SCENARIO_XML):
if [ -f $(SCENARIO_FILE) ]; then \
echo "Scenario XML is being fetched from $(realpath $(SCENARIO_FILE))"; \
mkdir -p $(dir $(HV_SCENARIO_XML)); \
python3 $(HV_CONFIG_TOOL_DIR)/scenario_config/default_populator.py $(HV_SCENARIO_XSD) $(SCENARIO_FILE) $(HV_SCENARIO_XML); \
python3 $(HV_CONFIG_TOOL_DIR)/scenario_config/default_populator.py $(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"; \