From 630f724b53a06a95df2f049567239cdf63e1b383 Mon Sep 17 00:00:00 2001 From: Erik Jaegervall Date: Mon, 11 Nov 2024 11:08:30 +0100 Subject: [PATCH] Binary exporter support for structs. Based on https://github.com/COVESA/vss-tools/pull/420 Signed-off-by: Ulf Bjorkengren Signed-off-by: Erik Jaegervall --- src/vss_tools/exporters/binary.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/vss_tools/exporters/binary.py b/src/vss_tools/exporters/binary.py index 63eee36a..8f29eae4 100644 --- a/src/vss_tools/exporters/binary.py +++ b/src/vss_tools/exporters/binary.py @@ -111,6 +111,8 @@ def export_node(node: VSSNode, f: BinaryIO): @clo.overlays_opt @clo.quantities_opt @clo.units_opt +@clo.types_opt +@clo.types_output_opt def cli( vspec: Path, output: Path, @@ -121,22 +123,32 @@ def cli( overlays: tuple[Path], quantities: tuple[Path], units: tuple[Path], + types: tuple[Path], + types_output: Path | None, ): """ Export to Binary. """ - tree, _ = get_trees( + tree, datatype_tree = get_trees( vspec=vspec, include_dirs=include_dirs, aborts=aborts, strict=strict, - extended_attributes=extended_attributes, quantities=quantities, units=units, + types=types, overlays=overlays, ) + log.info("Generating binary output...") + if datatype_tree: + if types_output: + with open(str(types_output), "wb") as f: + export_node(datatype_tree, f) + log.info("Binary datatype tree output generated in %s", types_output) + else: + log.warning("Ignoring type tree generation as no file name specified") with open(str(output), "wb") as f: export_node(tree, f) - log.info("Binary output generated in %s", output) + log.info("Binary main tree output generated in %s", output)