Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/modules/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ execute_process(
)

if(NOT "${ret}" STREQUAL "0")
message(FATAL_ERROR "dtc failed with return code: ${ret}")
message(FATAL_ERROR "dtc failed with return code: ${ret}\n${stderr}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to remove all this complex code and instead simply do:

execute_process(
  COMMAND ${DTC}
   ...
   ${ZEPHYR_DTS}
  OUTPUT_QUIET # Discard stdout
  WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
  COMMAND_ERROR_IS_FATAL ANY
  )

and then remove the

if(NOT "${ret}" STREQUAL "0")
 ...

logic below.

See also this comment for details: #78250 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So with COMMAND_ERROR_IS_FATAL, cmake only prints the output on failure? Or will will always prints the output no matter what with your proposed change?

Copy link
Contributor

@tejlmand tejlmand Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will print any output on standard error regardless of the error code.

Basically:

  • COMMAND_ERROR_IS_FATAL: Will fail CMake if return code is different from zero.
    Flag has no relation / impact on standard out or standard error.
  • No ERROR_OUTPUT, will print any message from standard error in the normal CMake output.
    Just like we are doing with message(... "... ${stderr}").

See: https://cmake.org/cmake/help/latest/command/execute_process.html

If no OUTPUT_* or ERROR_* options are given the output will be shared with the corresponding pipes of the CMake process itself.

Note: OUTPUT_QUIET discard only standard out, not standard error.

elseif(stderr)
# dtc printed warnings on stderr but did not fail.
# Display them as CMake warnings to draw attention.
Expand Down