scripts: west_command: spdx: Exit with non-zero code on failure

If the init or the generation fails, the resulting exit code should be
non-zero.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-12-24 15:44:58 +01:00 committed by Benjamin Cabé
parent 4e201f21c8
commit 1378669736

View file

@ -74,8 +74,9 @@ class ZephyrSpdx(WestCommand):
if query_ready:
self.inf("initialized; run `west build` then run `west spdx`")
else:
self.err("Couldn't create CMake file-based API query directory")
self.err("You can manually create an empty file at $BUILDDIR/.cmake/api/v1/query/codemodel-v2")
self.die("Couldn't create CMake file-based API query directory\n"
"You can manually create an empty file at "
"$BUILDDIR/.cmake/api/v1/query/codemodel-v2")
def do_run_spdx(self, args):
if not args.build_dir:
@ -110,4 +111,5 @@ class ZephyrSpdx(WestCommand):
# create the directory
os.makedirs(cfg.spdxDir, exist_ok=False)
makeSPDX(cfg)
if not makeSPDX(cfg):
self.die("Failed to create SPDX output")