From 6f4635f80c6c746c46f66f33af1fdecef705a22f Mon Sep 17 00:00:00 2001 From: Reto Schneider Date: Tue, 10 Sep 2024 21:51:21 +0200 Subject: [PATCH] cmake: modules: dts: Restore gen_defines.py warnings Ever since 059aae7c9168328279657433d77ae0f1d0214f1b (cmake: modules: dts: make Device Tree error messages more visible, PR #76472), warnings generated by gen_defines.py got only printed when the exit code signaled an error. Without this patch, the warning gets swallowed and the build continues: ``` $ west build --pristine --board nrf54l15pdk/nrf54l15/cpuapp \ samples/userspace/hello_world_user -- Found BOARD.dts: /boards/nordic/nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts -- Generated zephyr.dts: /build/zephyr/zephyr.dts ``` With this patch, the behavior is back to how it was before 059aae7c9168328279657433d77ae0f1d0214f1b: ``` $ west build --pristine --board nrf54l15pdk/nrf54l15/cpuapp \ samples/userspace/hello_world_user -- Found BOARD.dts: /nrf54l15pdk/nrf54l15pdk_nrf54l15_cpuapp.dts unit address and first address in 'reg' (0x5004c000) don't match for /soc/peripheral@50000000/vpr@4c000/mailbox@1 -- Generated zephyr.dts: zephyr/build/zephyr/zephyr.dts ``` Signed-off-by: Reto Schneider --- cmake/modules/dts.cmake | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/cmake/modules/dts.cmake b/cmake/modules/dts.cmake index 88abeb3ed43fa..ec0999d366b99 100644 --- a/cmake/modules/dts.cmake +++ b/cmake/modules/dts.cmake @@ -289,33 +289,13 @@ ${EXTRA_GEN_DEFINES_ARGS} execute_process( COMMAND ${CMD_GEN_DEFINES} WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - RESULT_VARIABLE ret - ERROR_VARIABLE stderr + COMMAND_ERROR_IS_FATAL ANY ) -if(NOT "${ret}" STREQUAL "0") - if (stderr) - # gen_defines.py failed after printing message(s) to stderr. - # Append stream content to the FATAL_ERROR message on a new line. - set(stderr "\n${stderr}") - else() - # gen_defines.py did not print anything on stderr. To inform users - # of this condition, set ${stderr} to "" to have this printed - # in the error message. Note that we do NOT want a newline, such that - # the error message is printed as a single line, e.g.: - # - # gen_defines.py failed with result code: 1 - stderr contents: - # - set(stderr "") - endif() - message(STATUS "In: ${PROJECT_BINARY_DIR}, command: ${CMD_GEN_DEFINES}") - message(FATAL_ERROR "gen_defines.py failed with result code: ${ret} - stderr contents: ${stderr}") -else() - zephyr_file_copy(${ZEPHYR_DTS}.new ${ZEPHYR_DTS} ONLY_IF_DIFFERENT) - zephyr_file_copy(${DEVICETREE_GENERATED_H}.new ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT) - file(REMOVE ${ZEPHYR_DTS}.new ${DEVICETREE_GENERATED_H}.new) - message(STATUS "Generated zephyr.dts: ${ZEPHYR_DTS}") - message(STATUS "Generated devicetree_generated.h: ${DEVICETREE_GENERATED_H}") -endif() +zephyr_file_copy(${ZEPHYR_DTS}.new ${ZEPHYR_DTS} ONLY_IF_DIFFERENT) +zephyr_file_copy(${DEVICETREE_GENERATED_H}.new ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT) +file(REMOVE ${ZEPHYR_DTS}.new ${DEVICETREE_GENERATED_H}.new) +message(STATUS "Generated zephyr.dts: ${ZEPHYR_DTS}") +message(STATUS "Generated devicetree_generated.h: ${DEVICETREE_GENERATED_H}") # # Run GEN_DRIVER_KCONFIG_SCRIPT.