From 73b73c91f40073f8c398828a34249edfd6f9bd60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Szprejda?= Date: Mon, 4 Mar 2024 18:03:21 +0100 Subject: [PATCH] West: Add option to supress elf/bin/hex file params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add capability allowing to suppress the --file parameters that can be passed to a west command runner. Signed-off-by: MichaƂ Szprejda --- scripts/west_commands/runners/core.py | 32 +++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/scripts/west_commands/runners/core.py b/scripts/west_commands/runners/core.py index fdc38013a9d..d77784486d0 100644 --- a/scripts/west_commands/runners/core.py +++ b/scripts/west_commands/runners/core.py @@ -247,6 +247,8 @@ class RunnerCaps: - file: whether the runner supports a --file option, which specifies exactly the file that should be used to flash, overriding any default discovered in the build directory. + + - hide_load_files: whether the elf/hex/bin file arguments should be hidden. ''' commands: Set[str] = field(default_factory=lambda: set(_RUNNERCAPS_COMMANDS)) @@ -257,6 +259,7 @@ class RunnerCaps: extload: bool = False tool_opt: bool = False file: bool = False + hide_load_files: bool = False def __post_init__(self): if not self.commands.issubset(_RUNNERCAPS_COMMANDS): @@ -511,18 +514,23 @@ class ZephyrBinaryRunner(abc.ABC): parser.add_argument('-f', '--file', help=argparse.SUPPRESS) parser.add_argument('-t', '--file-type', help=argparse.SUPPRESS) - parser.add_argument('--elf-file', - metavar='FILE', - action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), - help='path to zephyr.elf' if not caps.file else 'Deprecated, use -f/--file instead.') - parser.add_argument('--hex-file', - metavar='FILE', - action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), - help='path to zephyr.hex' if not caps.file else 'Deprecated, use -f/--file instead.') - parser.add_argument('--bin-file', - metavar='FILE', - action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), - help='path to zephyr.bin' if not caps.file else 'Deprecated, use -f/--file instead.') + if caps.hide_load_files: + parser.add_argument('--elf-file', help=argparse.SUPPRESS) + parser.add_argument('--hex-file', help=argparse.SUPPRESS) + parser.add_argument('--bin-file', help=argparse.SUPPRESS) + else: + parser.add_argument('--elf-file', + metavar='FILE', + action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), + help='path to zephyr.elf' if not caps.file else 'Deprecated, use -f/--file instead.') + parser.add_argument('--hex-file', + metavar='FILE', + action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), + help='path to zephyr.hex' if not caps.file else 'Deprecated, use -f/--file instead.') + parser.add_argument('--bin-file', + metavar='FILE', + action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), + help='path to zephyr.bin' if not caps.file else 'Deprecated, use -f/--file instead.') parser.add_argument('--erase', '--no-erase', nargs=0, action=_ToggleAction,