Skip to content

Commit

Permalink
west: sign: add new rimage option --if-tool-available
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marc-hb authored and nashif committed Apr 11, 2023
1 parent 5c4319d commit 2c80c4d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions scripts/west_commands/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def do_add_parser(self, parser_adder):
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')

Expand Down Expand Up @@ -201,6 +203,8 @@ def do_run(self, args, ignored):

# 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()
Expand Down Expand Up @@ -459,8 +463,13 @@ def sign(self, command, build_dir, build_conf, formats):
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 ####

Expand Down

0 comments on commit 2c80c4d

Please sign in to comment.