Skip to content

Commit

Permalink
Improve error messages when embedSdf.py fails (#1549)
Browse files Browse the repository at this point in the history
* Improve error message for missing EmbeddedSdf.cc
* Check embedSdf.py return code and print stderr

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters authored Mar 4, 2025
1 parent 9b37cf7 commit bf054f0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions sdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ endif()

# Generate the EmbeddedSdf.cc file, which contains all the supported SDF
# descriptions in a map of strings. The parser.cc file uses EmbeddedSdf.hh.
set(EMBEDDED_SDF_CC_PATH "${PROJECT_BINARY_DIR}/src/EmbeddedSdf.cc")
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sdf/embedSdf.py
--output-file "${PROJECT_BINARY_DIR}/src/EmbeddedSdf.cc"
--output-file "${EMBEDDED_SDF_CC_PATH}"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/sdf"
RESULT_VARIABLE EMBEDDED_SDF_RESULT
ERROR_VARIABLE EMBEDDED_SDF_ERROR
)
file(SIZE "${PROJECT_BINARY_DIR}/src/EmbeddedSdf.cc" OUT_SIZE)
if(${OUT_SIZE} EQUAL 0)
message(FATAL_ERROR "Problems executing ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sdf/embedSdf.py")
# check process return code
if(NOT EMBEDDED_SDF_RESULT EQUAL 0)
message(FATAL_ERROR "Error executing ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/sdf/embedSdf.py to create ${EMBEDDED_SDF_CC_PATH}: ${EMBEDDED_SDF_ERROR}")
endif()
# check that EmbeddedSdf.cc exists with non-zero size
# this should not happen if embedSdf.py was successful
if(EXISTS "${EMBEDDED_SDF_CC_PATH}")
file(SIZE "${EMBEDDED_SDF_CC_PATH}" EMBEDDED_SDF_CC_SIZE)
endif()
if("${EMBEDDED_SDF_CC_SIZE}" STREQUAL "0" OR "${EMBEDDED_SDF_CC_SIZE}" STREQUAL "")
message(FATAL_ERROR "${EMBEDDED_SDF_CC_PATH} is empty or does not exist")
endif()

# Generate aggregated SDF description files for use by the sdformat.org
Expand Down

0 comments on commit bf054f0

Please sign in to comment.