cmake: modules: dts: use devicetree stub file

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 <gerard@teslabs.com>
This commit is contained in:
Gerard Marull-Paretas 2023-10-11 13:18:19 +02:00 committed by Martí Bolívar
parent a4e9aed68d
commit e1137a3e5e
3 changed files with 16 additions and 9 deletions

14
boards/common/stub.dts Normal file
View File

@ -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>
/ {
};

View File

@ -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)
@ -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()
#

View File

@ -1 +0,0 @@
/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */