West: Add option to supress elf/bin/hex file params

Add capability allowing to suppress the --file parameters that can be
passed to a west command runner.

Signed-off-by: Michał Szprejda <mszprejda@antmicro.com>
This commit is contained in:
Michał Szprejda 2024-03-04 18:03:21 +01:00 committed by Alberto Escolar
commit 73b73c91f4

View file

@ -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,