Skip to content

Commit fe498ad

Browse files
Jordan Yatescarlescufi
authored andcommitted
scripts: snippets: add DTS_EXTRA_CPPFLAGS support
Add an additional option to the `append` schema for appending to the `DTS_EXTRA_CPPFLAGS` cmake cache variable, enabling finer control over the content of devicetree files. Signed-off-by: Jordan Yates <[email protected]>
1 parent e4bcd6b commit fe498ad

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

cmake/modules/configuration_files.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# - CONF_FILE: List of Kconfig fragments
1414
# - EXTRA_CONF_FILE: List of additional Kconfig fragments
1515
# - DTC_OVERLAY_FILE: List of devicetree overlay files
16+
# - EXTRA_DTC_OVERLAY_FILE List of additional devicetree overlay files
17+
# - DTS_EXTRA_CPPFLAGS List of additional devicetree preprocessor defines
1618
# - APPLICATION_CONFIG_DIR: Root folder for application configuration
1719
#
1820
# If any of the above variables are already set when this CMake module is
@@ -118,3 +120,4 @@ zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
118120

119121
zephyr_get(EXTRA_CONF_FILE SYSBUILD LOCAL VAR EXTRA_CONF_FILE OVERLAY_CONFIG MERGE REVERSE)
120122
zephyr_get(EXTRA_DTC_OVERLAY_FILE SYSBUILD LOCAL MERGE REVERSE)
123+
zephyr_get(DTS_EXTRA_CPPFLAGS SYSBUILD LOCAL MERGE REVERSE)

doc/build/snippets/writing.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ This :file:`snippet.yml` adds :file:`foo.conf` to the build:
156156
The path to :file:`foo.conf` is relative to the directory containing
157157
:file:`snippet.yml`.
158158

159+
``DTS_EXTRA_CPPFLAGS``
160+
**********************
161+
162+
This :file:`snippet.yml` adds ``DTS_EXTRA_CPPFLAGS`` CMake Cache variables
163+
to the build:
164+
165+
.. code-block:: yaml
166+
167+
name: foo
168+
append:
169+
DTS_EXTRA_CPPFLAGS: -DMY_DTS_CONFIGURE
170+
171+
Adding these flags enables control over the content of a devicetree file.
172+
159173
Board-specific settings
160174
***********************
161175

scripts/schemas/snippet-schema.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ schema;append-schema:
1313
type: str
1414
EXTRA_CONF_FILE:
1515
type: str
16+
DTS_EXTRA_CPPFLAGS:
17+
type: str
1618

1719
type: map
1820
mapping:

scripts/snippets.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ def append_value(variable, value):
5757
if not path.is_file():
5858
_err(f'snippet file {pathobj}: {variable}: file not found: {path}')
5959
return f'"{path}"'
60+
if variable in ('DTS_EXTRA_CPPFLAGS'):
61+
return f'"{value}"'
6062
_err(f'unknown append variable: {variable}')
6163

6264
for variable, value in snippet_data.get('append', {}).items():

0 commit comments

Comments
 (0)