west: sign: add new rimage option --if-tool-available
Moving `west sign` from `west flash` to `west build` for rimage has
multiple advantages (including a bit more consistency with
imgtool). However it makes `west build` fail when rimage is missing.
To avoid forcing every CI and developer who never used it before to
install rimage, make signing optional when passing new `west sign`
option --if-tool-available. A clear warning is printed.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
diff --git a/scripts/west_commands/sign.py b/scripts/west_commands/sign.py
index d21ec47..cf6a5ba 100644
--- a/scripts/west_commands/sign.py
+++ b/scripts/west_commands/sign.py
@@ -133,6 +133,8 @@
help='''path to the tool itself, if needed''')
group.add_argument('-D', '--tool-data', default=None,
help='''path to a tool-specific data/configuration directory, if needed''')
+ group.add_argument('--if-tool-available', action='store_true',
+ help='''Do not fail if rimage is missing, just warn.''')
group.add_argument('tool_args', nargs='*', metavar='tool_opt',
help='extra option(s) to pass to the signing tool')
@@ -201,6 +203,8 @@
# Delegate to the signer.
if args.tool == 'imgtool':
+ if args.if_tool_available:
+ log.die('imgtool does not support --if-tool-available')
signer = ImgtoolSigner()
elif args.tool == 'rimage':
signer = RimageSigner()
@@ -459,8 +463,13 @@
else:
tool_path = shutil.which('rimage')
if not tool_path:
- log.die('rimage not found; either install it',
- 'or provide --tool-path')
+ err_msg = 'rimage not found; either install it or provide --tool-path'
+ if args.if_tool_available:
+ log.wrn(err_msg)
+ log.wrn('zephyr binary _not_ signed!')
+ return
+ else:
+ log.die(err_msg)
#### -c sof/rimage/config/signing_schema.toml ####