Skip to content

Commit fc00875

Browse files
scripts: west_commands: build: support cmake arguments via --cmake-opt
Support cmake options specified via argument --cmake-opt, in order to avoid `--` in alias commands. Signed-off-by: Thorsten Klein <[email protected]>
1 parent 965e921 commit fc00875

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/west_commands/build.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def do_add_parser(self, parser_adder):
119119
group = parser.add_argument_group('cmake and build tool')
120120
group.add_argument('-c', '--cmake', action='store_true',
121121
help='force a cmake run')
122+
group.add_argument('--cmake-opt', action='append',
123+
help='''same as using '-- cmake_opt', but avoid
124+
using -- (e.g. helpful in alias commands)''')
122125
group.add_argument('--cmake-only', action='store_true',
123126
help="just run cmake; don't build (implies -c)")
124127
group.add_argument('--domain', action='append',
@@ -262,7 +265,7 @@ def do_run(self, args, remainder):
262265
else:
263266
self.die("test item path does not exist")
264267

265-
self._run_cmake(board, origin, self.args.cmake_opts)
268+
self._run_cmake(board, origin)
266269
if args.cmake_only:
267270
return
268271

@@ -624,7 +627,7 @@ def _sanity_check(self):
624627
self.source_dir = self._find_source_dir()
625628
self._sanity_check_source_dir()
626629

627-
def _run_cmake(self, board, origin, cmake_opts):
630+
def _run_cmake(self, board, origin):
628631
if board is None and config_getboolean('board_warn', True):
629632
self.wrn('This looks like a fresh build and BOARD is unknown;',
630633
"so it probably won't work. To fix, use",
@@ -643,6 +646,8 @@ def _run_cmake(self, board, origin, cmake_opts):
643646
cmake_opts = [f'-DBOARD={board}']
644647
else:
645648
cmake_opts = []
649+
if self.args.cmake_opt:
650+
cmake_opts.extend(self.args.cmake_opt)
646651
if self.args.cmake_opts:
647652
cmake_opts.extend(self.args.cmake_opts)
648653
if self.args.snippets:

0 commit comments

Comments
 (0)