-
Notifications
You must be signed in to change notification settings - Fork 8.2k
cmake: introduce snippets for common configuration #40669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,4 +11,7 @@ config BOARD | |
| config BT_CTLR | ||
| default BT | ||
|
|
||
| config USE_DT_CODE_PARTITION | ||
| default y | ||
|
|
||
| endif # BOARD_NRF52840DK_NRF52840 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Copyright (c) 2022, Commonwealth Scientific and Industrial Research | ||
| * Organisation (CSIRO) ABN 41 687 119 230. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /delete-node/ &standalone_partition; | ||
|
|
||
| &flash0 { | ||
|
|
||
| partitions { | ||
| compatible = "fixed-partitions"; | ||
| #address-cells = <1>; | ||
| #size-cells = <1>; | ||
|
|
||
| boot_partition: partition@0 { | ||
| label = "mcuboot"; | ||
| reg = <0x000000000 0x0000C000>; | ||
| }; | ||
| slot0_partition: partition@c000 { | ||
| label = "image-0"; | ||
| reg = <0x0000C000 0x00067000>; | ||
| }; | ||
| slot1_partition: partition@73000 { | ||
| label = "image-1"; | ||
| reg = <0x00073000 0x00067000>; | ||
| }; | ||
| scratch_partition: partition@da000 { | ||
| label = "image-scratch"; | ||
| reg = <0x000da000 0x0001e000>; | ||
| }; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright (c) 2022, Commonwealth Scientific and Industrial Research | ||
| * Organisation (CSIRO) ABN 41 687 119 230. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "mb_partitions.dtsi" | ||
|
|
||
| / { | ||
| chosen { | ||
| zephyr,code-partition = &boot_partition; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* | ||
| * Copyright (c) 2022, Commonwealth Scientific and Industrial Research | ||
| * Organisation (CSIRO) ABN 41 687 119 230. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "mb_partitions.dtsi" | ||
|
|
||
| / { | ||
| chosen { | ||
| zephyr,code-partition = &slot0_partition; | ||
| }; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CONFIG_USB_DEVICE_STACK=y |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /* | ||
| * Copyright (c) 2021, Commonwealth Scientific and Industrial Research | ||
| * Organisation (CSIRO) ABN 41 687 119 230. | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| &usbd { | ||
| compatible = "nordic,nrf-usbd"; | ||
| status = "okay"; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
| BUILD_USAGE = '''\ | ||
| west build [-h] [-b BOARD[@REV]]] [-d BUILD_DIR] | ||
| [-t TARGET] [-p {auto, always, never}] [-c] [--cmake-only] | ||
| [-n] [-o BUILD_OPT] [-f] | ||
| [-n] [-o BUILD_OPT] [-f] [-s SNIPPET] | ||
| [source_dir] -- [cmake_opt [cmake_opt ...]] | ||
| ''' | ||
|
|
||
|
|
@@ -100,10 +100,10 @@ def do_add_parser(self, parser_adder): | |
|
|
||
| parser.add_argument('-b', '--board', | ||
| help='board to build for with optional board revision') | ||
| # Hidden option for backwards compatibility | ||
| parser.add_argument('-s', '--source-dir', help=argparse.SUPPRESS) | ||
|
||
| parser.add_argument('-d', '--build-dir', | ||
| help='build directory to create or use') | ||
| parser.add_argument('-s', '--snippet', default=[], action='append', | ||
| help='''snippets to apply when building''') | ||
| self.add_force_arg(parser) | ||
|
|
||
| group = parser.add_argument_group('cmake and build tool') | ||
|
|
@@ -137,17 +137,10 @@ def do_run(self, args, remainder): | |
| self.config_board = config_get('board', None) | ||
| log.dbg('args: {} remainder: {}'.format(args, remainder), | ||
| level=log.VERBOSE_EXTREME) | ||
| # Store legacy -s option locally | ||
| source_dir = self.args.source_dir | ||
| self._parse_remainder(remainder) | ||
| # Parse testcase.yaml or sample.yaml files for additional options. | ||
| if self.args.test_item: | ||
| self._parse_test_item() | ||
| if source_dir: | ||
| if self.args.source_dir: | ||
| log.die("source directory specified twice:({} and {})".format( | ||
| source_dir, self.args.source_dir)) | ||
| self.args.source_dir = source_dir | ||
| log.dbg('source_dir: {} cmake_opts: {}'.format(self.args.source_dir, | ||
| self.args.cmake_opts), | ||
| level=log.VERBOSE_EXTREME) | ||
|
|
@@ -440,6 +433,8 @@ def _run_cmake(self, board, origin, cmake_opts): | |
| cmake_opts = [] | ||
| if self.args.cmake_opts: | ||
| cmake_opts.extend(self.args.cmake_opts) | ||
| if self.args.snippet: | ||
| cmake_opts.extend(['-DSNIPPETS={}'.format(" ".join(self.args.snippet))]) | ||
|
|
||
| user_args = config_get('cmake-args', None) | ||
| if user_args: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments on this:
-shas been deprecated for some time, then I think it's good practice to have a period between removing the argument before using that same argument for something new.snippethave it's ownwest buildargument whenCONF_FILE,DTC_OVERLAY_FILE,SHIELDetc. doesn't have ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In an ideal world yes, but the end result is going to be the same. If
-sis removed, any scripts using it will crash. If-sis reused, any scripts using it will crash. Unfortunately I can't go back and remove it a year ago. Of course if the name changes from "snippet" then there is no need to use-s.Because its goal is to cover common use cases, which IMO means the ease-of-use of
west build -b board -s usb samples/basic/minimaloverwest build -b board samples/basic/minimal -- -DSNIPPETS="usb"warrants it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say
-DOVERLAY_CONFIGorDTC_OVERLAY_FILEare much better candidates for having extra arguments than snippets.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree; I think snippets do rise to the level of deserving their own option.
I want to ask what the practical differences between snippets and shields are at this point, in terms of their behavior. Shields seem to be a special case of snippets, morally speaking.
Taking @petejohanson since he's taken an interest in adding more comprehensive shield related options to west build elsewhere.