Skip to content

Commit

Permalink
cmake: modules: dts: use devicetree stub file
Browse files Browse the repository at this point in the history
By providing a devicetree stub file, we make sure some internal macros
required by devicetree.h are generated in devicetree_generated.h. This
makes sure that systems without devicetree can continue working without
extra ifdeffery.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull authored and mbolivar-ampere committed Oct 20, 2023
1 parent a4e9aed commit e1137a3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
14 changes: 14 additions & 0 deletions boards/common/stub.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
* SPDX-License-Identifier: Apache-2.0
*/

/* empty stub file provided for systems not using devicetree */

/dts-v1/;

#include <skeleton.dtsi>

/ {

};
10 changes: 2 additions & 8 deletions cmake/modules/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ set(DTS_CMAKE ${PROJECT_BINARY_DIR}/dts.cmake)
# modules.
set(VENDOR_PREFIXES dts/bindings/vendor-prefixes.txt)

#
# Halt execution early if there is no devicetree.
#

# TODO: What to do about non-posix platforms where NOT CONFIG_HAS_DTS (xtensa)?
# Drop support for NOT CONFIG_HAS_DTS perhaps?
set_ifndef(DTS_SOURCE ${BOARD_DIR}/${BOARD}.dts)
Expand All @@ -138,10 +134,8 @@ if(EXISTS ${DTS_SOURCE})
list(APPEND DTS_SOURCE ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
endif()
else()
# If we don't have a devicetree after all, there's not much to do.
set(header_template ${ZEPHYR_BASE}/misc/generated/generated_header.template)
zephyr_file_copy(${header_template} ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT)
return()
# If we don't have a devicetree, provide an empty stub
set(DTS_SOURCE ${ZEPHYR_BASE}/boards/common/stub.dts)
endif()

#
Expand Down
1 change: 0 additions & 1 deletion misc/generated/generated_header.template

This file was deleted.

0 comments on commit e1137a3

Please sign in to comment.