Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone gz sdf executable #1539

Merged
merged 24 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d823820
Implement gz sdf as standalone executable
scpeters Jun 9, 2024
ce14de5
Merge branch 'sdf15' into scpeters/gz_sdf_executable
scpeters Oct 3, 2024
aafefa1
Merge branch 'sdf15' into scpeters/gz_sdf_executable
azeey Dec 7, 2024
891e490
Updating ruby script to use standalone executable (#1489)
sauk2 Jan 23, 2025
f4fc058
Merge branch 'sdf15' into scpeters/gz_sdf_executable
azeey Jan 23, 2025
c4f155f
Moved tests and deleted redundant files
sauk2 Feb 7, 2025
756ba94
Updated cmake to build moved test
sauk2 Feb 7, 2025
193a1f1
Skipped creation of static lib for standalone exe creation
sauk2 Feb 7, 2025
699c5ae
Added includes
sauk2 Feb 7, 2025
7b27baa
Restoring previous files to save commit history
sauk2 Feb 11, 2025
9714658
Removed gz files from cmd
sauk2 Feb 11, 2025
5dae7f4
Moved cmd files by preserving history
sauk2 Feb 11, 2025
71edff4
Added namespace to cmd line hooks
sauk2 Feb 11, 2025
d834355
Changed types from int to bool for flags
sauk2 Feb 11, 2025
22d78cc
Defined test config path as alias and populated it from cmake
sauk2 Feb 11, 2025
40576fe
Merge branch 'sdf15' into gz_sdf_executable
j-rivero Feb 17, 2025
51e8485
Removed GZ_PROGRAM dependency from sdf_descriptions target
sauk2 Feb 24, 2025
b15e767
Added concise description and validation to -g option
sauk2 Feb 26, 2025
3505c3d
Removed function to print gz version
sauk2 Feb 27, 2025
eacb7b3
Added dependency on -p for print specific flags
sauk2 Feb 27, 2025
3f35036
Added back files for eventual git rename
sauk2 Feb 27, 2025
5fdfb42
Moved cmd source files
sauk2 Feb 27, 2025
0f40dd5
Added modification to cmd source files
sauk2 Feb 27, 2025
8d3b4d5
Merge branch 'sdf15' into gz_sdf_executable
sauk2 Mar 5, 2025
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
36 changes: 18 additions & 18 deletions sdf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ execute_process(
# Generate aggregated SDF description files for use by the sdformat.org
# website. If the description files change, the generated full*.sdf files need
# to be removed before running this target.
if (GZ_PROGRAM)

# Update this list as new sdformat spec versions are added.
set(sdf_desc_versions 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12)
# Update this list as new sdformat spec versions are added.
set(sdf_desc_versions 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12)

set(description_targets)
foreach(desc_ver ${sdf_desc_versions})
string(REPLACE "." "-" desc_ver_dash ${desc_ver})
list(APPEND description_targets ${CMAKE_CURRENT_BINARY_DIR}/full_${desc_ver_dash}.sdf)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/full_${desc_ver_dash}.sdf
COMMAND
${CMAKE_COMMAND} -E env GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>
${GZ_PROGRAM}
ARGS sdf -d ${desc_ver} > ${CMAKE_CURRENT_BINARY_DIR}/full_${desc_ver_dash}.sdf
COMMENT "Generating full description for spec ${desc_ver}"
VERBATIM)
endforeach()
add_custom_target(sdf_descriptions DEPENDS ${description_targets} ${PROJECT_LIBRARY_TARGET_NAME})
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the removal of PROJECT_LIBRARY_TARGET_NAME from DEPENDS intended?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sauk2 this final question and we are good to go !

Copy link
Contributor Author

@sauk2 sauk2 Feb 25, 2025

Choose a reason for hiding this comment

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

Oh sorry, I forgot to reply. This change was made by @azeey as a part of this commit (615048c) of this PR (#1489). He'd be the best person to clarify so tagging him here!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're adding a dependency on gz-sdformat-sdf below, which is ultimately what is used to generate these files, this target no longer needs to depend on PROJECT_LIBRARY_TARGET_NAME

endif()
set(description_targets)
foreach(desc_ver ${sdf_desc_versions})
string(REPLACE "." "-" desc_ver_dash ${desc_ver})
list(APPEND description_targets ${CMAKE_CURRENT_BINARY_DIR}/full_${desc_ver_dash}.sdf)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/full_${desc_ver_dash}.sdf
COMMAND
${CMAKE_COMMAND} -E env GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>
$<TARGET_FILE:gz-sdformat-sdf>
ARGS sdf -d ${desc_ver} > ${CMAKE_CURRENT_BINARY_DIR}/full_${desc_ver_dash}.sdf
COMMENT "Generating full description for spec ${desc_ver}"
VERBATIM)
endforeach()
add_custom_target(sdf_descriptions DEPENDS ${description_targets})
# Add a dependency on the gz-sdformat-sdf target which is created in in ../cmd/CMakeLists
add_dependencies(sdf_descriptions gz-sdformat-sdf)
12 changes: 0 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ target_include_directories(${PROJECT_LIBRARY_TARGET_NAME}
)

if (BUILD_TESTING)
# Build this test file only if Gazebo Tools is installed.
if (NOT GZ_PROGRAM)
list(REMOVE_ITEM gtest_sources gz_TEST.cc)
endif()

add_library(library_for_tests OBJECT
Converter.cc
EmbeddedSdf.cc
Expand Down Expand Up @@ -120,13 +115,6 @@ if (BUILD_TESTING)
ENVIRONMENT
SDF_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)

if (TARGET UNIT_gz_TEST)
target_compile_definitions(UNIT_gz_TEST PRIVATE
-DGZ_PATH="${GZ_PROGRAM}"
-DDETAIL_GZ_CONFIG_PATH="${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>"
-DGZ_TEST_LIBRARY_PATH="${PROJECT_BINARY_DIR}/src")
endif()
endif()

add_subdirectory(cmd)
48 changes: 43 additions & 5 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
# Build sdf CLI executable
set(sdf_executable gz-sdformat-sdf)
add_executable(${sdf_executable} sdf_main.cc gz.cc ../FrameSemantics.cc)
target_link_libraries(${sdf_executable}
gz-utils${GZ_UTILS_VER}::cli
${PROJECT_LIBRARY_TARGET_NAME}
TINYXML2::TINYXML2
)
install(
TARGETS ${sdf_executable}
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/
)

# Build the unit tests only if Gazebo tools is installed
if(BUILD_TESTING AND GZ_PROGRAM)
gz_build_tests(TYPE UNIT
SOURCES
gz_TEST.cc
INCLUDE_DIRS
${PROJECT_SOURCE_DIR}/test
TEST_LIST
test_list
LIB_DEPS
gz-utils${GZ_UTILS_VER}::gz-utils${GZ_UTILS_VER}
${EXTRA_TEST_LIB_DEPS}
ENVIRONMENT
SDF_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)

if(TARGET UNIT_gz_TEST)
target_compile_definitions(UNIT_gz_TEST
PRIVATE
"GZ_PATH=\"${GZ_PROGRAM}\""
"DETAIL_GZ_CONFIG_PATH=\"${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>\""
"GZ_TEST_LIBRARY_PATH=\"$<TARGET_FILE_DIR:${PROJECT_LIBRARY_TARGET_NAME}>\""
)
endif()
endif()

#===============================================================================
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
# Ex: cmdsdformat0.rb
set(cmd_script_generated_test
set(cmd_script_generated_test
"${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/cmd${PROJECT_NAME}.rb")
set(cmd_script_configured_test
set(cmd_script_configured_test
"${CMAKE_CURRENT_BINARY_DIR}/test_cmd${PROJECT_NAME}.rb.configured")

# Set the library_location variable to the full path of the library file within
# the build directory.
set(library_location "$<TARGET_FILE:${PROJECT_NAME}>")
set(library_location "$<TARGET_FILE:${sdf_executable}>")

configure_file(
"cmd${PROJECT_NAME_NO_VERSION_LOWER}.rb.in"
Expand All @@ -20,7 +59,6 @@ file(GENERATE
OUTPUT "${cmd_script_generated_test}"
INPUT "${cmd_script_configured_test}")


#===============================================================================
# Used for the installed version.
# Generate the ruby script that gets installed.
Expand All @@ -37,7 +75,7 @@ else()
set(library_location_prefix "${CMAKE_INSTALL_LIBDIR}")
endif()

set(library_location "../../../${library_location_prefix}/$<TARGET_FILE_NAME:${PROJECT_NAME}>")
set(library_location "../../../${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${sdf_executable}>")

configure_file(
"cmd${PROJECT_NAME_NO_VERSION_LOWER}.rb.in"
Expand Down
Loading
Loading