scripts: run_common: fix command line --hex-file and friends
This is yet another bug introduced by the move to runners.yaml.
Sigh. I should have tested this better.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
diff --git a/scripts/west_commands/run_common.py b/scripts/west_commands/run_common.py
index cfb7e84..1e91c1b 100644
--- a/scripts/west_commands/run_common.py
+++ b/scripts/west_commands/run_common.py
@@ -188,10 +188,17 @@
parser = argparse.ArgumentParser(prog=runner_name)
add_parser_common(command, parser=parser)
runner_cls.add_parser(parser)
- final_args, unknown = parser.parse_known_args(args=final_argv)
+ args, unknown = parser.parse_known_args(args=final_argv)
if unknown:
log.die(f'runner {runner_name} received unknown arguments: {unknown}')
+ # Override args with any user_args. The latter must take
+ # precedence, or e.g. --hex-file on the command line would be
+ # ignored in favor of a board.cmake setting.
+ for a, v in vars(user_args).items():
+ if v is not None:
+ setattr(args, a, v)
+
# Create the RunnerConfig from the values assigned to common
# arguments. This is a hacky way to go about this; probably
# ZephyrBinaryRunner should define what it needs to make this
@@ -200,9 +207,7 @@
#
# Use that RunnerConfig to create the ZephyrBinaryRunner instance
# and call its run().
- runner = runner_cls.create(runner_cfg_from_args(final_args,
- build_dir),
- final_args)
+ runner = runner_cls.create(runner_cfg_from_args(args, build_dir), args)
try:
runner.run(command_name)
except ValueError as ve: