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 - file: whether the runner supports a --file option, which specifies
exactly the file that should be used to flash, overriding any default exactly the file that should be used to flash, overriding any default
discovered in the build directory. 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)) commands: Set[str] = field(default_factory=lambda: set(_RUNNERCAPS_COMMANDS))
@ -257,6 +259,7 @@ class RunnerCaps:
extload: bool = False extload: bool = False
tool_opt: bool = False tool_opt: bool = False
file: bool = False file: bool = False
hide_load_files: bool = False
def __post_init__(self): def __post_init__(self):
if not self.commands.issubset(_RUNNERCAPS_COMMANDS): if not self.commands.issubset(_RUNNERCAPS_COMMANDS):
@ -511,6 +514,11 @@ class ZephyrBinaryRunner(abc.ABC):
parser.add_argument('-f', '--file', help=argparse.SUPPRESS) parser.add_argument('-f', '--file', help=argparse.SUPPRESS)
parser.add_argument('-t', '--file-type', help=argparse.SUPPRESS) parser.add_argument('-t', '--file-type', help=argparse.SUPPRESS)
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', parser.add_argument('--elf-file',
metavar='FILE', metavar='FILE',
action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None), action=(partial(depr_action, cls=cls, replacement='-f/--file') if caps.file else None),