From 483adc984e025451fc5d5f4466b3b4a225be82c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=AD=20Bol=C3=ADvar?= Date: Wed, 13 Nov 2019 07:24:18 -0800 Subject: [PATCH] scripts: fix misc-flasher runner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the misc-flasher runner usable by passing the build directory to the underlying tool. Fixes: #20658 Signed-off-by: Martí Bolívar --- scripts/west_commands/runners/misc.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/west_commands/runners/misc.py b/scripts/west_commands/runners/misc.py index 8ae7a7e5dad..26dfc81e2bc 100644 --- a/scripts/west_commands/runners/misc.py +++ b/scripts/west_commands/runners/misc.py @@ -15,12 +15,13 @@ from runners.core import ZephyrBinaryRunner, RunnerCaps class MiscFlasher(ZephyrBinaryRunner): '''Runner for handling special purpose flashing commands.''' - def __init__(self, cfg, args): + def __init__(self, cfg, command, args): super().__init__(cfg) - if not args: + if not command: # This is a board definition error, not a user error, # so we can do it now and not in do_run(). raise ValueError('no command was given') + self.command = command self.args = args @classmethod @@ -33,13 +34,17 @@ class MiscFlasher(ZephyrBinaryRunner): @classmethod def do_add_parser(cls, parser): - parser.add_argument('args', nargs='+', - help='command to run (and any extra arguments)') + parser.add_argument('command', + help='''command to run; it will be passed the + build directory as its first argument''') + parser.add_argument('args', nargs='*', + help='''additional arguments to pass after the build + directory''') @classmethod def create(cls, cfg, args): - return MiscFlasher(cfg, args.args) + return MiscFlasher(cfg, args.command, args.args) - def do_run(self, command, **kwargs): - self.require(self.args[0]) - self.check_call(self.args) + def do_run(self, *args, **kwargs): + self.require(self.command) + self.check_call([self.command, self.cfg.build_dir] + self.args)