Skip to content

Commit aac1584

Browse files
hlord2000MaureenHelm
authored andcommitted
west_commands: build: add extra file arguments
Adds an argument to include additional .conf or .overlay files Example use: ``` west build -b nrf52840dk/nrf52840 -p --extra-conf foo.conf ``` ``` west build -b nrf52840dk/nrf52840 -p --extra-dtc-overlay foo.overlay ``` Or: ``` west build -b nrf52840dk/nrf52840 -p --extra-conf foo.conf --extra-conf bar.conf ``` ``` west build -b nrf52840dk/nrf52840 -p --extra-dtc-overlay foo.overlay --extra-dtc-overlay bar.overlay ``` Signed-off-by: Helmut Lord <[email protected]>
1 parent 7f40866 commit aac1584

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

scripts/west_commands/build.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
[-t TARGET] [-p {auto, always, never}] [-c] [--cmake-only]
2929
[-n] [-o BUILD_OPT] [-f]
3030
[--sysbuild | --no-sysbuild] [--domain DOMAIN]
31+
[--extra-conf FILE.conf]
32+
[--extra-dtc-overlay FILE.overlay]
3133
[source_dir] -- [cmake_opt [cmake_opt ...]]
3234
'''
3335

@@ -150,6 +152,20 @@ def do_add_parser(self, parser_adder):
150152
Do not use this option with manually specified
151153
-DSHIELD... cmake arguments: the results are
152154
undefined''')
155+
group.add_argument('--extra-conf', dest='extra_conf_files', metavar='EXTRA_CONF_FILE',
156+
action='append', default=[],
157+
help='''add the argument to EXTRA_CONF_FILE; may be given
158+
multiple times. Forces CMake to run again if given.
159+
Do not use this option with manually specified
160+
-DEXTRA_CONF_FILE... cmake arguments: the results are
161+
undefined''')
162+
group.add_argument('--extra-dtc-overlay', dest='extra_dtc_overlay_files',
163+
metavar='EXTRA_DTC_OVERLAY_FILE', action='append', default=[],
164+
help='''add the argument to EXTRA_DTC_OVERLAY_FILE; may be given
165+
multiple times. Forces CMake to run again if given.
166+
Do not use this option with manually specified
167+
-DEXTRA_DTC_OVERLAY_FILE... cmake arguments: the results are
168+
undefined''')
153169

154170
group = parser.add_mutually_exclusive_group()
155171
group.add_argument('--sysbuild', action='store_true',
@@ -223,7 +239,8 @@ def do_run(self, args, remainder):
223239
self._update_cache()
224240
if (self.args.cmake or self.args.cmake_opts or
225241
self.args.cmake_only or self.args.snippets or
226-
self.args.shields):
242+
self.args.shields or self.args.extra_conf_files or
243+
self.args.extra_dtc_overlay_files):
227244
self.run_cmake = True
228245
else:
229246
self.run_cmake = True
@@ -570,6 +587,13 @@ def _run_cmake(self, board, origin, cmake_opts):
570587
cmake_opts.append(f'-DSNIPPET={";".join(self.args.snippets)}')
571588
if self.args.shields:
572589
cmake_opts.append(f'-DSHIELD={";".join(self.args.shields)}')
590+
if self.args.extra_conf_files:
591+
cmake_opts.append(f'-DEXTRA_CONF_FILE={";".join(self.args.extra_conf_files)}')
592+
if self.args.extra_dtc_overlay_files:
593+
cmake_opts.append(
594+
f'-DEXTRA_DTC_OVERLAY_FILE='
595+
f'{";".join(self.args.extra_dtc_overlay_files)}'
596+
)
573597

574598
user_args = config_get('cmake-args', None)
575599
if user_args:

0 commit comments

Comments
 (0)