Skip to content

Commit 2270c34

Browse files
committed
[nrf fromlist] cmake: dts: Use temporary file for dts.cmake with sysbuild
Uses a temporary file when sysbuild is being used for images then uses CMake to copy to the correct file if it has changed. This prevents a ping-pong of configuring and building cycle when nothing has changed and there is sysbuild code which loads in the devicetree data from an image Upstream PR #: 81340 Signed-off-by: Jamie McCrae <[email protected]>
1 parent b524b0e commit 2270c34

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

cmake/modules/dts.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,32 @@ endif()
321321
#
322322
# Run GEN_DTS_CMAKE_SCRIPT.
323323
#
324+
# For sysbuild, use a temp file and copy it to the original file if it differs, this prevents
325+
# a cycle of configuring and building multiple times due to the dts.cmake file of images having a
326+
# newer modification time than the sysbuild build.ninja file, despite the output having not changed
327+
#
328+
329+
if(SYSBUILD)
330+
set(dts_tmp_cmake _tmp)
331+
else()
332+
set(dts_tmp_cmake)
333+
endif()
324334

325335
execute_process(
326336
COMMAND ${PYTHON_EXECUTABLE} ${GEN_DTS_CMAKE_SCRIPT}
327337
--edt-pickle ${EDT_PICKLE}
328-
--cmake-out ${DTS_CMAKE}
338+
--cmake-out ${DTS_CMAKE}${dts_tmp_cmake}
329339
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
330340
RESULT_VARIABLE ret
331341
)
332342
if(NOT "${ret}" STREQUAL "0")
333343
message(FATAL_ERROR "gen_dts_cmake.py failed with return code: ${ret}")
334344
else()
345+
if(SYSBUILD)
346+
file(COPY_FILE ${DTS_CMAKE}${dts_tmp_cmake} ${DTS_CMAKE} ONLY_IF_DIFFERENT INPUT_MAY_BE_RECENT)
347+
set(dts_tmp_cmake)
348+
endif()
349+
335350
message(STATUS "Including generated dts.cmake file: ${DTS_CMAKE}")
336351
include(${DTS_CMAKE})
337352
endif()

0 commit comments

Comments
 (0)