Skip to content

Commit

Permalink
Use standalone executables with ign tool (#216)
Browse files Browse the repository at this point in the history
Add ign-transport-topic and ign-transport-service executables
in lib/ignition/transport10 folder for use by ign ruby command.
The cli component of ignition-utils is used to parse CLI arguments.

Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Steve Peters <[email protected]>

Co-authored-by: Steve Peters <[email protected]>
Co-authored-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
3 people committed May 18, 2021
1 parent 3ae2925 commit 7040522
Show file tree
Hide file tree
Showing 11 changed files with 416 additions and 397 deletions.
8 changes: 6 additions & 2 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Used only for internal testing.
set(ign_library_path "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(ign_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate a configuration file for internal testing.
# Note that the major version of the library is included in the name.
# Ex: transport0.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_BINARY_DIR}/test/conf/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
"${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured" @ONLY)

file(GENERATE
OUTPUT "${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured")

# Used for the installed version.
set(ign_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
Expand Down
32 changes: 0 additions & 32 deletions configure.bat

This file was deleted.

10 changes: 1 addition & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
# "gtest_sources" variable.
ign_get_libsources_and_unittests(sources gtest_sources)

# Skip command line tests for Windows, see
# https://github.com/ignitionrobotics/ign-transport/issues/104
if (MSVC)
list(REMOVE_ITEM gtest_sources ign_TEST.cc)
endif()

if (MSVC)
# Warning #4251 is the "dll-interface" warning that tells you when types used
# by a class are not being exported. These generated source files have private
Expand Down Expand Up @@ -66,6 +60,4 @@ if(MSVC)
endif()

# Command line support.
if(NOT WIN32)
add_subdirectory(cmd)
endif()
add_subdirectory(cmd)
72 changes: 68 additions & 4 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,76 @@
# Collect source files into the "sources" variable and unit test files into the
# "gtest_sources" variable.
ign_get_libsources_and_unittests(sources gtest_sources)

# Skip command line tests for Windows, see
# https://github.com/ignitionrobotics/ign-transport/issues/104
if (MSVC)
list(REMOVE_ITEM gtest_sources ign_TEST.cc)
endif()

# Make a small static lib of command line functions
add_library(ign STATIC ign.cc)
target_link_libraries(ign
${PROJECT_LIBRARY_TARGET_NAME}
)

# Build topic CLI executable
set(topic_executable ign-transport-topic)
add_executable(${topic_executable} topic_main.cc)
target_link_libraries(${topic_executable}
ign
ignition-utils${IGN_UTILS_VER}::cli
${PROJECT_LIBRARY_TARGET_NAME}
)
install(TARGETS ${topic_executable} DESTINATION ${IGN_LIB_INSTALL_DIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/)

# Build service CLI executable
set(service_executable ign-transport-service)
add_executable(${service_executable} service_main.cc)
target_link_libraries(${service_executable}
ign
ignition-utils${IGN_UTILS_VER}::cli
${PROJECT_LIBRARY_TARGET_NAME}
)
install(TARGETS ${service_executable} DESTINATION ${IGN_LIB_INSTALL_DIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/)

# Build the unit tests.
ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
TEST_LIST test_list
LIB_DEPS ${EXTRA_TEST_LIB_DEPS})

foreach(test ${test_list})
target_link_libraries(${test} ign)

# Inform each test of its output directory so it knows where to call the
# auxiliary files from. Using a generator expression here is useful for
# multi-configuration generators, like Visual Studio.
target_compile_definitions(${test} PRIVATE
"DETAIL_IGN_TRANSPORT_TEST_DIR=\"$<TARGET_FILE_DIR:${test}>\""
"IGN_TEST_LIBRARY_PATH=\"$<TARGET_FILE_DIR:${PROJECT_LIBRARY_TARGET_NAME}>\"")

endforeach()

if (TARGET UNIT_ign_TEST)
set_tests_properties(
UNIT_ign_TEST
PROPERTIES
ENVIRONMENT
"IGN_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>"
)
endif()

#===============================================================================
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
# Ex: cmdtransport0.rb
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${cmd_script_generated_test}.configured")
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${CMAKE_CURRENT_BINARY_DIR}/test_cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.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_LIBRARY_TARGET_NAME}>")
set(service_exe_location "$<TARGET_FILE:${service_executable}>")
set(topic_exe_location "$<TARGET_FILE:${topic_executable}>")

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
Expand All @@ -29,7 +92,8 @@ set(cmd_script_configured "${cmd_script_generated}.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(library_location "../../../${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${PROJECT_LIBRARY_TARGET_NAME}>")
set(service_exe_location "../../../${CMAKE_INSTALL_LIBDIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${service_executable}>")
set(topic_exe_location "../../../${CMAKE_INSTALL_LIBDIR}/ignition/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}/$<TARGET_FILE_NAME:${topic_executable}>")

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

0 comments on commit 7040522

Please sign in to comment.