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

Merge gz-launch6 ➡️ gz-launch7 #251

Merged
merged 3 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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()

Check warning on line 29 in src/InstallationDirectories.cc

View check run for this annotation

Codecov / codecov/patch

src/InstallationDirectories.cc#L29

Added line #L29 was not covered by tests
{
return gz::common::joinPaths(
getInstallPrefix(), GZ_LAUNCH_PLUGIN_RELATIVE_INSTALL_PATH);

Check warning on line 32 in src/InstallationDirectories.cc

View check run for this annotation

Codecov / codecov/patch

src/InstallationDirectories.cc#L32

Added line #L32 was not covered by tests
}

std::string getInitialConfigPath()

Check warning on line 35 in src/InstallationDirectories.cc

View check run for this annotation

Codecov / codecov/patch

src/InstallationDirectories.cc#L35

Added line #L35 was not covered by tests
{
return gz::common::joinPaths(
getInstallPrefix(), GZ_LAUNCH_INITIAL_CONFIG_RELATIVE_PATH);

Check warning on line 38 in src/InstallationDirectories.cc

View check run for this annotation

Codecov / codecov/patch

src/InstallationDirectories.cc#L38

Added line #L38 was not covered by tests
}

}
}
}
3 changes: 2 additions & 1 deletion 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 @@ -1083,7 +1084,7 @@

gz::common::SystemPaths systemPaths;
systemPaths.SetPluginPathEnv("GZ_LAUNCH_PLUGIN_PATH");
systemPaths.AddPluginPaths(GZ_LAUNCH_PLUGIN_INSTALL_PATH);
systemPaths.AddPluginPaths(gz::launch::getPluginInstallPath());

Check warning on line 1087 in src/Manager.cc

View check run for this annotation

Codecov / codecov/patch

src/Manager.cc#L1087

Added line #L1087 was not covered by tests

// Add LD_LIBRARY_PATH
#ifdef __linux__
Expand Down
3 changes: 2 additions & 1 deletion 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
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" const char *configPath()
{
return GZ_LAUNCH_INITIAL_CONFIG_PATH;
std::string configPath = gz::launch::getPluginInstallPath();
return strdup(configPath.c_str());

Check warning on line 36 in src/cmd/gz.cc

View check run for this annotation

Codecov / codecov/patch

src/cmd/gz.cc#L35-L36

Added lines #L35 - L36 were not covered by tests
}

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