-
Notifications
You must be signed in to change notification settings - Fork 8.2k
sysbuild: Add support for snippets #73254
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Copyright (c) 2024 Nordic Semiconductor | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| zephyr_get(SB_SNIPPET) | ||
| if(NOT SB_SNIPPET AND SNIPPET) | ||
| set_ifndef(SB_SNIPPET ${SNIPPET}) | ||
| endif() | ||
| set(SNIPPET_NAMESPACE SB_SNIPPET) | ||
| set(SNIPPET_PYTHON_EXTRA_ARGS --sysbuild) | ||
| set(SNIPPET_APP_DIR ${APP_DIR}) | ||
| include(${ZEPHYR_BASE}/cmake/modules/snippets.cmake) | ||
|
|
||
| set(SNIPPET_NAMESPACE) | ||
| set(SNIPPET_PYTHON_EXTRA_ARGS) | ||
| set(SNIPPET_APP_DIR) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(test_snippets) | ||
|
|
||
| FILE(GLOB app_sources src/*.c) | ||
| target_sources(app PRIVATE ${app_sources}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Copyright 2024 Nordic Semiconductor ASA | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| menu "Zephyr" | ||
| source "Kconfig.zephyr" | ||
| endmenu | ||
|
|
||
| # Test values set by the snippet config overlays and tested by the test logic | ||
| config TEST_FOO_VAL | ||
| int "Test value" | ||
| default 12 | ||
| help | ||
| This option's value should be overridden by sysbuild. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Copyright 2024 Nordic Semiconductor ASA | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| config TEST_FOO_VAL | ||
| int "Test value" | ||
| default 0 | ||
| help | ||
| This option's value should be overridden by the 'foo' snippet config overlay. | ||
|
|
||
| config EXPECTED_SB_TEST_FOO_VAL | ||
| int "Expected sysbuild test value" | ||
| default 999999 | ||
| help | ||
| Expected sysbuild value for the test. | ||
|
|
||
| config EXPECTED_APP_TEST_FOO_VAL | ||
| int "Expected application test value" | ||
| default 999999 | ||
| help | ||
| Expected application value for the test. | ||
|
|
||
| source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CONFIG_ZTEST=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /* | ||
| * Copyright (c) 2024 Nordic Semiconductor ASA | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| /* Empty file */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| set(SNIPPET_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") | ||
| set(sysbuild_snippets_SNIPPET_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "") | ||
| set(EXTRA_ZEPHYR_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/test_module" CACHE INTERNAL "test_module directory") | ||
|
|
||
| find_package(Sysbuild REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
|
|
||
| project(sysbuild LANGUAGES) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CONFIG_TEST_FOO_VAL=18382 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| SB_CONFIG_TEST_FOO_VAL=464372 |
4 changes: 4 additions & 0 deletions
4
tests/cmake/sysbuild_snippets/sysbuild/snippets/foo/snippet.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| name: foo | ||
| append: | ||
| SB_EXTRA_CONF_FILE: sb.conf | ||
| EXTRA_CONF_FILE: app.conf |
24 changes: 24 additions & 0 deletions
24
tests/cmake/sysbuild_snippets/sysbuild/test_module/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| function(${SYSBUILD_CURRENT_MODULE_NAME}_post_cmake) | ||
| ExternalProject_Get_Property(${DEFAULT_IMAGE} BINARY_DIR) | ||
| import_kconfig(CONFIG_ ${BINARY_DIR}/zephyr/.config) | ||
|
|
||
| if("${SB_CONFIG_TEST_FOO_VAL}" STREQUAL "${CONFIG_TEST_FOO_VAL}") | ||
| message(FATAL_ERROR "Values match (sysbuild and app): ${SB_CONFIG_TEST_FOO_VAL} and ${CONFIG_TEST_FOO_VAL}") | ||
| else() | ||
| message(NOTICE "Values diverge (sysbuild and app)") | ||
| endif() | ||
|
|
||
| if("${SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL}" STREQUAL "${SB_CONFIG_TEST_FOO_VAL}") | ||
| message(NOTICE "Values match (sysbuild and snippet): ${SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL} and ${SB_CONFIG_TEST_FOO_VAL}") | ||
| else() | ||
| message(FATAL_ERROR "Values diverge (sysbuild and snippet): ${SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL} and ${SB_CONFIG_TEST_FOO_VAL}") | ||
| endif() | ||
|
|
||
| if("${SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL}" STREQUAL "${CONFIG_TEST_FOO_VAL}") | ||
| message(NOTICE "Values match (app and snippet): ${SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL} and ${CONFIG_TEST_FOO_VAL}") | ||
| else() | ||
| message(FATAL_ERROR "Values diverge (app and snippet): ${SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL} and ${CONFIG_TEST_FOO_VAL}") | ||
| endif() | ||
| endfunction() |
2 changes: 2 additions & 0 deletions
2
tests/cmake/sysbuild_snippets/sysbuild/test_module/zephyr/module.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| build: | ||
| sysbuild-cmake: . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| common: | ||
| sysbuild: true | ||
| tags: sysbuild_snippets sysbuild | ||
| platform_allow: | ||
| - native_sim | ||
| integration_platforms: | ||
| - native_sim | ||
|
|
||
| tests: | ||
| # Test the initial state with no snippets applied | ||
| buildsystem.sysbuild.snippets.none: | ||
| extra_args: | ||
| - SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL=0 | ||
| - SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL=12 | ||
| # Test the `foo` snippet in sysbuild | ||
| buildsystem.sysbuild.snippets.applied: | ||
| extra_args: | ||
| - SNIPPET=foo | ||
| - SB_CONFIG_EXPECTED_SB_TEST_FOO_VAL=464372 | ||
| - SB_CONFIG_EXPECTED_APP_TEST_FOO_VAL=18382 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.