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>
This commit is contained in:
Marc Herbert 2023-03-03 01:45:45 +00:00 committed by Anas Nashif
parent 5c4319d54f
commit 2c80c4daa4

View file

@ -133,6 +133,8 @@ class Sign(Forceable):
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 @@ class Sign(Forceable):
# 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 @@ class RimageSigner(Signer):
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 ####