From 28c76dbf9d5a367ca00641b5f35c660f8052ecb5 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Tue, 19 Mar 2024 13:58:19 -0500 Subject: [PATCH 1/5] Fix msvc warning (#250) Signed-off-by: Addisu Z. Taddese --- src/Manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Manager.cc b/src/Manager.cc index 42f51e1b..21fa9737 100644 --- a/src/Manager.cc +++ b/src/Manager.cc @@ -381,7 +381,7 @@ ManagerPrivate::ManagerPrivate() const auto pid_seed = std::hash()( std::this_thread::get_id()); std::seed_seq seed_value{time_seed, pid_seed}; - std::vector seeds(1); + std::vector seeds(1); seed_value.generate(seeds.begin(), seeds.end()); math::Rand::Seed(seeds[0]); } From 17835ca9d41ca5fa0b0973cb8c82d4e5812451d1 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Wed, 3 Apr 2024 16:42:30 +0200 Subject: [PATCH 2/5] Add optional binary relocatability (#218) Signed-off-by: Silvio Traversaro --- CMakeLists.txt | 3 +- include/gz/launch/InstallationDirectories.hh | 46 ++++++++++++++++++++ include/gz/launch/config.hh.in | 4 +- src/CMakeLists.txt | 13 ++++++ src/InstallationDirectories.cc | 43 ++++++++++++++++++ src/Manager.cc | 3 +- src/cmd/CMakeLists.txt | 3 +- src/cmd/gz.cc | 5 ++- test/integration/CMakeLists.txt | 5 ++- test/performance/CMakeLists.txt | 4 +- test/regression/CMakeLists.txt | 4 +- 11 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 include/gz/launch/InstallationDirectories.hh create mode 100644 src/InstallationDirectories.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e19ca64..6d2fe831 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,8 @@ gz_configure_project(VERSION_SUFFIX) # Set project-specific options #============================================================================ -set(GZ_LAUNCH_PLUGIN_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins/") +set(GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH "${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins/") +set(GZ_LAUNCH_PLUGIN_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}") #============================================================================ # Search for project-specific dependencies diff --git a/include/gz/launch/InstallationDirectories.hh b/include/gz/launch/InstallationDirectories.hh new file mode 100644 index 00000000..f9fd398d --- /dev/null +++ b/include/gz/launch/InstallationDirectories.hh @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2023 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GZ_LAUNCH_INSTALLATION_DIRECTORIES_HH_ +#define GZ_LAUNCH_INSTALLATION_DIRECTORIES_HH_ + +#include + +#include +#include + +namespace gz +{ + namespace launch + { + inline namespace GZ_LAUNCH_VERSION_NAMESPACE { + + /// \brief getInstallPrefix return the install prefix of the library + /// i.e. CMAKE_INSTALL_PREFIX unless the library has been moved + GZ_LAUNCH_VISIBLE std::string getInstallPrefix(); + + /// \brief getPluginInstallPath return the plugin install path + GZ_LAUNCH_VISIBLE std::string getPluginInstallPath(); + + /// \brief getInitialConfigPath return the initial config path + GZ_LAUNCH_VISIBLE std::string getInitialConfigPath(); + + } + } +} + +#endif diff --git a/include/gz/launch/config.hh.in b/include/gz/launch/config.hh.in index b0fb1f30..73609ae4 100644 --- a/include/gz/launch/config.hh.in +++ b/include/gz/launch/config.hh.in @@ -30,8 +30,8 @@ #define GZ_LAUNCH_VERSION_HEADER "Gazebo Launch, version ${PROJECT_VERSION_FULL}\nCopyright (C) 2019 Open Source Robotics Foundation.\nReleased under the Apache 2.0 License.\n\n" -#define GZ_LAUNCH_INITIAL_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/${GZ_DATA_INSTALL_DIR}/configs" +#define GZ_LAUNCH_INITIAL_CONFIG_PATH _Pragma ("GCC warning \"'GZ_LAUNCH_INITIAL_CONFIG_PATH' macro is deprecated, use gz::launch::getInitialConfigPath() function instead. \"") "${CMAKE_INSTALL_PREFIX}/${GZ_DATA_INSTALL_DIR}/configs" -#define GZ_LAUNCH_PLUGIN_INSTALL_PATH "${GZ_LAUNCH_PLUGIN_INSTALL_PATH}" +#define GZ_LAUNCH_PLUGIN_INSTALL_PATH _Pragma ("GCC warning \"'GZ_LAUNCH_PLUGIN_INSTALL_PATH' macro is deprecated, use gz::launch::getPluginInstallPath() function instead. \"") "${GZ_LAUNCH_PLUGIN_INSTALL_PATH}" #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5f87b11..d3b5350d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,7 @@ # add_subdirectory(plugins) set (sources + InstallationDirectories.cc Manager.cc ) @@ -10,6 +11,16 @@ set (gtest_sources # Create the library target. gz_create_core_library(SOURCES ${sources}) +gz_add_get_install_prefix_impl(GET_INSTALL_PREFIX_FUNCTION gz::launch::getInstallPrefix + GET_INSTALL_PREFIX_HEADER gz/launch/InstallationDirectories.hh + OVERRIDE_INSTALL_PREFIX_ENV_VARIABLE GZ_LAUNCH_INSTALL_PREFIX) + +set_property( + SOURCE InstallationDirectories.cc + PROPERTY COMPILE_DEFINITIONS + GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH="${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}" + GZ_LAUNCH_INITIAL_CONFIG_RELATIVE_PATH="${GZ_DATA_INSTALL_DIR}/configs" +) # Link the libraries that we always need. target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} @@ -31,6 +42,8 @@ gz_build_tests(TYPE UNIT SOURCES ${gtest_sources} LIB_DEPS ${PROJECT_LIBRARY_TARGET_NAME} gz-common${GZ_COMMON_VER}::gz-common${GZ_COMMON_VER} + ENVIRONMENT + GZ_LAUNCH_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ) add_subdirectory(cmd) diff --git a/src/InstallationDirectories.cc b/src/InstallationDirectories.cc new file mode 100644 index 00000000..39dcaacf --- /dev/null +++ b/src/InstallationDirectories.cc @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include + +#include + +namespace gz +{ +namespace launch +{ +inline namespace GZ_LAUNCH_VERSION_NAMESPACE { + +std::string getPluginInstallPath() +{ + return gz::common::joinPaths( + getInstallPrefix(), GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH); +} + +std::string getInitialConfigPath() +{ + return gz::common::joinPaths( + getInstallPrefix(), GZ_LAUNCH_INITIAL_CONFIG_RELATIVE_PATH); +} + +} +} +} diff --git a/src/Manager.cc b/src/Manager.cc index 400d95a3..9ca71c87 100644 --- a/src/Manager.cc +++ b/src/Manager.cc @@ -57,6 +57,7 @@ #include #include "gz/launch/config.hh" +#include "gz/launch/InstallationDirectories.hh" #include "gz/launch/Plugin.hh" #include "vendor/backward.hpp" @@ -1089,7 +1090,7 @@ void ManagerPrivate::LoadPlugin(const tinyxml2::XMLElement *_elem) gz::common::SystemPaths systemPaths; systemPaths.SetPluginPathEnv("GZ_LAUNCH_PLUGIN_PATH"); - systemPaths.AddPluginPaths(GZ_LAUNCH_PLUGIN_INSTALL_PATH); + systemPaths.AddPluginPaths(gz::launch::getPluginInstallPath()); // Add LD_LIBRARY_PATH #ifdef __linux__ diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index b87f706d..49be965e 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -32,7 +32,8 @@ install( # Build the unit tests. gz_build_tests(TYPE UNIT SOURCES ${gtest_sources} TEST_LIST test_list - LIB_DEPS ${EXTRA_TEST_LIB_DEPS}) + LIB_DEPS ${EXTRA_TEST_LIB_DEPS} + ENVIRONMENT GZ_LAUNCH_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) foreach(test ${test_list}) target_link_libraries(${test} gz) diff --git a/src/cmd/gz.cc b/src/cmd/gz.cc index d770541b..cdd559c7 100644 --- a/src/cmd/gz.cc +++ b/src/cmd/gz.cc @@ -15,9 +15,11 @@ * */ #include +#include #include #include "gz/launch/config.hh" +#include "gz/launch/InstallationDirectories.hh" #include "gz.hh" #include "../Manager.hh" @@ -30,7 +32,8 @@ extern "C" char *gzVersion() ////////////////////////////////////////////////// extern "C" const char *configPath() { - return GZ_LAUNCH_INITIAL_CONFIG_PATH; + std::string configPath = gz::launch::getPluginInstallPath(); + return configPath.c_str(); } ////////////////////////////////////////////////// diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 1c6496c6..f4162ed8 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -10,7 +10,10 @@ if(NOT WIN32) # Disable test on Windows, it deals with UNIX signals set(tests faulty_plugins.cc) - gz_build_tests(TYPE INTEGRATION SOURCES ${tests} TEST_LIST test_targets) + gz_build_tests(TYPE INTEGRATION + SOURCES ${tests} + TEST_LIST test_targets + ENVIRONMENT GZ_LAUNCH_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) foreach(test ${test_targets}) target_compile_definitions(${test} PRIVATE "bad_plugins_LIB=\"$\"") diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt index a73bfddb..872a9539 100644 --- a/test/performance/CMakeLists.txt +++ b/test/performance/CMakeLists.txt @@ -4,4 +4,6 @@ set(tests) link_directories(${PROJECT_BINARY_DIR}/test) -gz_build_tests(TYPE PERFORMANCE SOURCES ${tests}) +gz_build_tests(TYPE PERFORMANCE + SOURCES ${tests} + ENVIRONMENT GZ_LAUNCH_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) diff --git a/test/regression/CMakeLists.txt b/test/regression/CMakeLists.txt index aac9ecda..1e94deee 100644 --- a/test/regression/CMakeLists.txt +++ b/test/regression/CMakeLists.txt @@ -5,4 +5,6 @@ set(tests link_directories(${PROJECT_BINARY_DIR}/test) -gz_build_tests(TYPE REGRESSION SOURCES ${tests}) +gz_build_tests(TYPE REGRESSION + SOURCES ${tests} + ENVIRONMENT GZ_LAUNCH_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) From 5938a17c8d0605c1b6547d2a23ec73cba2064032 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Fri, 5 Apr 2024 11:55:46 -0500 Subject: [PATCH 3/5] Fix bug where address of local variable was returned (#252) Signed-off-by: Addisu Z. Taddese --- src/cmd/gz.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/gz.cc b/src/cmd/gz.cc index cdd559c7..25109c9e 100644 --- a/src/cmd/gz.cc +++ b/src/cmd/gz.cc @@ -33,7 +33,7 @@ extern "C" char *gzVersion() extern "C" const char *configPath() { std::string configPath = gz::launch::getPluginInstallPath(); - return configPath.c_str(); + return strdup(configPath.c_str()); } ////////////////////////////////////////////////// From a3ea50d7325dc39bbf9df7cb7d559130e7a27364 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Mon, 8 Apr 2024 18:47:19 -0500 Subject: [PATCH 4/5] Use relative install paths for plugin shared libraries and gz-tools data (#253) Signed-off-by: Addisu Z. Taddese --- plugins/joy_to_twist/CMakeLists.txt | 2 +- plugins/joystick/CMakeLists.txt | 2 +- plugins/sim_factory/CMakeLists.txt | 2 +- plugins/sim_gui/CMakeLists.txt | 2 +- plugins/sim_server/CMakeLists.txt | 2 +- plugins/websocket_server/CMakeLists.txt | 2 +- src/cmd/CMakeLists.txt | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/joy_to_twist/CMakeLists.txt b/plugins/joy_to_twist/CMakeLists.txt index ca374032..ff9c15ec 100644 --- a/plugins/joy_to_twist/CMakeLists.txt +++ b/plugins/joy_to_twist/CMakeLists.txt @@ -11,4 +11,4 @@ target_link_libraries(${plugin} gz-transport${GZ_TRANSPORT_VER}::core ) -install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_INSTALL_PATH}) +install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}) diff --git a/plugins/joystick/CMakeLists.txt b/plugins/joystick/CMakeLists.txt index 71a3f359..e2a6ab41 100644 --- a/plugins/joystick/CMakeLists.txt +++ b/plugins/joystick/CMakeLists.txt @@ -11,4 +11,4 @@ target_link_libraries(${plugin} gz-plugin${GZ_PLUGIN_VER}::core ) -install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_INSTALL_PATH}) +install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}) diff --git a/plugins/sim_factory/CMakeLists.txt b/plugins/sim_factory/CMakeLists.txt index e292621b..9c7d8eb8 100644 --- a/plugins/sim_factory/CMakeLists.txt +++ b/plugins/sim_factory/CMakeLists.txt @@ -13,4 +13,4 @@ target_link_libraries(${plugin_lower} gz-plugin${GZ_PLUGIN_VER}::core ) -install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_INSTALL_PATH}) +install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}) diff --git a/plugins/sim_gui/CMakeLists.txt b/plugins/sim_gui/CMakeLists.txt index 76a16765..50732cf6 100644 --- a/plugins/sim_gui/CMakeLists.txt +++ b/plugins/sim_gui/CMakeLists.txt @@ -16,4 +16,4 @@ target_link_libraries(${plugin_lower} gz-plugin${GZ_PLUGIN_VER}::core ) -install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_INSTALL_PATH}) +install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}) diff --git a/plugins/sim_server/CMakeLists.txt b/plugins/sim_server/CMakeLists.txt index f27edce3..1b7d77ff 100644 --- a/plugins/sim_server/CMakeLists.txt +++ b/plugins/sim_server/CMakeLists.txt @@ -13,4 +13,4 @@ target_link_libraries(${plugin_lower} gz-plugin${GZ_PLUGIN_VER}::core ) -install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_INSTALL_PATH}) +install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}) diff --git a/plugins/websocket_server/CMakeLists.txt b/plugins/websocket_server/CMakeLists.txt index 8b32bd17..a751695c 100644 --- a/plugins/websocket_server/CMakeLists.txt +++ b/plugins/websocket_server/CMakeLists.txt @@ -25,5 +25,5 @@ if (websockets_FOUND) gz-transport${GZ_TRANSPORT_VER}::core ) - install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_INSTALL_PATH}) + install (TARGETS ${plugin} DESTINATION ${GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH}) endif() diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index cfb3ad3d..461c6617 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -80,7 +80,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/launch${PROJECT_VERSION_MAJOR}.bash_completion.sh DESTINATION - ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${GZ_TOOLS_VER}.completion.d) + ${CMAKE_INSTALL_DATAROOTDIR}/gz/gz${GZ_TOOLS_VER}.completion.d) #=============================================================================== # Generate the ruby script for internal testing. @@ -151,7 +151,7 @@ configure_file( # Install the yaml configuration files in an unversioned location. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml -DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/) +DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gz/) # Install the ruby command line library in an unversioned location. install(FILES ${cmd_script_generated} DESTINATION lib/ruby/gz) From 1317511d365d1b2c312c86f9062b8a4b7bfdc132 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 11 Apr 2024 12:47:22 -0500 Subject: [PATCH 5/5] Prepare for 7.1.0 (#254) Signed-off-by: Addisu Z. Taddese --- CMakeLists.txt | 2 +- Changelog.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9b82c0b..a6e0a3b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5.1 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(gz-launch7 VERSION 7.0.0) +project(gz-launch7 VERSION 7.1.0) #============================================================================ # Find gz-cmake diff --git a/Changelog.md b/Changelog.md index 11d4a593..fb5787af 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,26 @@ ## Gazebo Launch 7.x +### Gazebo Launch 7.1.0 (2024-04-11) + +1. Use relative install paths for plugin shared libraries and gz-tools data + * [Pull request #253](https://github.com/gazebosim/gz-launch/pull/253) + +1. Fix bug where address of local variable was returned + * [Pull request #252](https://github.com/gazebosim/gz-launch/pull/252) + +1. Add optional binary relocatability + * [Pull request #218](https://github.com/gazebosim/gz-launch/pull/218) + +1. Fix windows warnings + * [Pull request #199](https://github.com/gazebosim/gz-launch/pull/199) + * [Pull request #250](https://github.com/gazebosim/gz-launch/pull/250) + +1. Update CI badges in README + * [Pull request #239](https://github.com/gazebosim/gz-launch/pull/239) + +1. Infrastructure + * [Pull request #238](https://github.com/gazebosim/gz-launch/pull/238) + ### Gazebo Launch 7.0.0 (2023-09-29) 1. Documentation fixes