Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gz-launch7' into azeey/package_xml
Browse files Browse the repository at this point in the history
  • Loading branch information
azeey committed Apr 11, 2024
2 parents 076f4d1 + 1317511 commit 2641784
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 19 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
46 changes: 46 additions & 0 deletions include/gz/launch/InstallationDirectories.hh
Original file line number Diff line number Diff line change
@@ -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 <string>

#include <gz/launch/config.hh>
#include <gz/launch/Export.hh>

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
4 changes: 2 additions & 2 deletions include/gz/launch/config.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion plugins/joy_to_twist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion plugins/joystick/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion plugins/sim_factory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion plugins/sim_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion plugins/sim_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
2 changes: 1 addition & 1 deletion plugins/websocket_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
13 changes: 13 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# add_subdirectory(plugins)

set (sources
InstallationDirectories.cc
Manager.cc
)

Expand All @@ -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}
Expand All @@ -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)
43 changes: 43 additions & 0 deletions src/InstallationDirectories.cc
Original file line number Diff line number Diff line change
@@ -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 <gz/launch/config.hh>
#include <gz/launch/InstallationDirectories.hh>

#include <gz/common/Filesystem.hh>

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);
}

}
}
}
5 changes: 3 additions & 2 deletions src/Manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <gz/plugin/Loader.hh>

#include "gz/launch/config.hh"
#include "gz/launch/InstallationDirectories.hh"
#include "gz/launch/Plugin.hh"

#include "vendor/backward.hpp"
Expand Down Expand Up @@ -381,7 +382,7 @@ ManagerPrivate::ManagerPrivate()
const auto pid_seed = std::hash<std::thread::id>()(
std::this_thread::get_id());
std::seed_seq seed_value{time_seed, pid_seed};
std::vector<size_t> seeds(1);
std::vector<std::uint32_t> seeds(1);
seed_value.generate(seeds.begin(), seeds.end());
math::Rand::Seed(seeds[0]);
}
Expand Down Expand Up @@ -1083,7 +1084,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__
Expand Down
7 changes: 4 additions & 3 deletions src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -79,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.
Expand Down Expand Up @@ -150,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)
5 changes: 4 additions & 1 deletion src/cmd/gz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*
*/
#include <cstring>
#include <string>
#include <gz/common/Console.hh>

#include "gz/launch/config.hh"
#include "gz/launch/InstallationDirectories.hh"
#include "gz.hh"
#include "../Manager.hh"

Expand All @@ -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 strdup(configPath.c_str());
}

//////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=\"$<TARGET_FILE:bad_plugins>\"")
Expand Down
4 changes: 3 additions & 1 deletion test/performance/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
4 changes: 3 additions & 1 deletion test/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

0 comments on commit 2641784

Please sign in to comment.