From 2c80c4daa4fbb879b257699bc3894083612b0861 Mon Sep 17 00:00:00 2001 From: Marc Herbert Date: Fri, 3 Mar 2023 01:45:45 +0000 Subject: [PATCH] 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 --- scripts/west_commands/sign.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/west_commands/sign.py b/scripts/west_commands/sign.py index d21ec4766686dd..cf6a5ba0f72bce 100644 --- a/scripts/west_commands/sign.py +++ b/scripts/west_commands/sign.py @@ -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') @@ -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() @@ -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 ####