Skip to content

Commit b4903d4

Browse files
mbolivar-nordicnashif
authored andcommitted
west sign: adjust find_imgtool helper
Have it return a list, which is prepended to the final arguments list passed to subprocess. No behavioral changes expected, but this enables making it contain multiple strings instead of just one. Signed-off-by: Martí Bolívar <[email protected]>
1 parent fb2b77c commit b4903d4

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

scripts/west_commands/sign.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def sign(self, command, build_dir, bcfg, formats):
213213
args = command.args
214214
b = pathlib.Path(build_dir)
215215

216-
tool_path = self.find_imgtool(command, args)
216+
imgtool = self.find_imgtool(command, args)
217217
# The vector table offset is set in Kconfig:
218218
vtoff = self.get_cfg(command, bcfg, 'CONFIG_ROM_START_OFFSET')
219219
# Flash device write alignment and the partition's slot size
@@ -259,11 +259,11 @@ def sign(self, command, build_dir, bcfg, formats):
259259
# We provide a default --version in case the user is just
260260
# messing around and doesn't want to set one. It will be
261261
# overridden if there is a --version in args.tool_args.
262-
sign_base = [tool_path, 'sign',
263-
'--version', '0.0.0+0',
264-
'--align', str(align),
265-
'--header-size', str(vtoff),
266-
'--slot-size', str(size)]
262+
sign_base = imgtool + ['sign',
263+
'--version', '0.0.0+0',
264+
'--align', str(align),
265+
'--header-size', str(vtoff),
266+
'--slot-size', str(size)]
267267
sign_base.extend(args.tool_args)
268268

269269
if not args.quiet:
@@ -291,13 +291,13 @@ def find_imgtool(command, args):
291291
command.check_force(shutil.which(args.tool_path),
292292
'--tool-path {}: not an executable'.
293293
format(args.tool_path))
294-
tool_path = args.tool_path
295-
else:
296-
tool_path = shutil.which('imgtool') or shutil.which('imgtool.py')
297-
if not tool_path:
298-
log.die('imgtool not found; either install it',
299-
'(e.g. "pip3 install imgtool") or provide --tool-path')
300-
return tool_path
294+
return [args.tool_path]
295+
296+
imgtool = shutil.which('imgtool') or shutil.which('imgtool.py')
297+
if not imgtool:
298+
log.die('imgtool not found; either install it',
299+
'(e.g. "pip3 install imgtool") or provide --tool-path')
300+
return [imgtool]
301301

302302
@staticmethod
303303
def get_cfg(command, bcfg, item):

0 commit comments

Comments
 (0)