From e1137a3e5e7c08531065485519fced3f02c73e47 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Wed, 11 Oct 2023 13:18:19 +0200 Subject: [PATCH] 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 --- boards/common/stub.dts | 14 ++++++++++++++ cmake/modules/dts.cmake | 10 ++-------- misc/generated/generated_header.template | 1 - 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 boards/common/stub.dts delete mode 100644 misc/generated/generated_header.template diff --git a/boards/common/stub.dts b/boards/common/stub.dts new file mode 100644 index 00000000000..ebb8b852a92 --- /dev/null +++ b/boards/common/stub.dts @@ -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 + +/ { + +}; diff --git a/cmake/modules/dts.cmake b/cmake/modules/dts.cmake index 8236195ff85..8cdd94cd574 100644 --- a/cmake/modules/dts.cmake +++ b/cmake/modules/dts.cmake @@ -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() # diff --git a/misc/generated/generated_header.template b/misc/generated/generated_header.template deleted file mode 100644 index 2b323cd20e1..00000000000 --- a/misc/generated/generated_header.template +++ /dev/null @@ -1 +0,0 @@ -/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */