diff --git a/hypervisor/scripts/makefile/config.mk b/hypervisor/scripts/makefile/config.mk index b45a23f2f..19a8b9828 100644 --- a/hypervisor/scripts/makefile/config.mk +++ b/hypervisor/scripts/makefile/config.mk @@ -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"; \ diff --git a/misc/config_tools/scenario_config/default_populator.py b/misc/config_tools/scenario_config/default_populator.py index d3d74fc54..fd4fef0a6 100755 --- a/misc/config_tools/scenario_config/default_populator.py +++ b/misc/config_tools/scenario_config/default_populator.py @@ -43,7 +43,7 @@ class DefaultValuePopulatingStage(PipelineStage): populator.transform(etree) obj.set("scenario_etree", etree) -def main(xsd_file, xml_file, out_file): +def main(args): from xml_loader import XMLLoadStage from lxml_loader import LXMLLoadStage @@ -54,15 +54,18 @@ def main(xsd_file, xml_file, out_file): DefaultValuePopulatingStage(), ]) - obj = PipelineObject(schema_path = xsd_file, scenario_path = xml_file) + obj = PipelineObject(schema_path = args.schema, scenario_path = args.scenario) pipeline.run(obj) - obj.get("scenario_etree").write(out_file) + obj.get("scenario_etree").write(args.out) if __name__ == "__main__": + config_tools_dir = os.path.join(os.path.dirname(__file__), "..") + schema_dir = os.path.join(config_tools_dir, "schema") + parser = argparse.ArgumentParser(description="Populate a given scenario XML with default values of nonexistent nodes") - parser.add_argument("xsd", help="Path to the schema of scenario XMLs") - parser.add_argument("xml", help="Path to the scenario XML file from users") + parser.add_argument("scenario", help="Path to the scenario XML file from users") parser.add_argument("out", nargs="?", default="out.xml", help="Path where the output is placed") + parser.add_argument("--schema", default=os.path.join(schema_dir, "config.xsd"), help="the XML schema that defines the syntax of scenario XMLs") args = parser.parse_args() - main(args.xsd, args.xml, args.out) + main(args) diff --git a/misc/config_tools/scenario_config/validator.py b/misc/config_tools/scenario_config/validator.py old mode 100644 new mode 100755