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

ign -> gz Provisional Finale: Source Migration : gz-plugin #93

Merged
merged 4 commits into from
Jul 23, 2022
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
6 changes: 3 additions & 3 deletions .github/ci/packages.apt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
libignition-cmake3-dev
libignition-tools2-dev
libignition-utils2-cli-dev
libgz-cmake3-dev
libgz-tools2-dev
libgz-utils2-cli-dev
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@v2
- name: Compile and test
id: ci
uses: ignition-tooling/action-ignition-ci@focal
uses: gazebo-tooling/action-gz-ci@focal
with:
codecov-enabled: true
cppcheck-enabled: true
Expand All @@ -25,4 +25,4 @@ jobs:
uses: actions/checkout@v2
- name: Compile and test
id: ci
uses: ignition-tooling/action-ignition-ci@jammy
uses: gazebo-tooling/action-gz-ci@jammy
2 changes: 1 addition & 1 deletion .github/workflows/pr-collection-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ jobs:
steps:
- name: Add collection labels
if: github.event.action == 'opened'
uses: ignition-tooling/pr-collection-labeler@v1
uses: gazebo-tooling/pr-collection-labeler@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
22 changes: 11 additions & 11 deletions MigrationFromCommon.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Migration Instructions (from common::Plugin)

This file provides migration instructions for `ignition` library developers to
This file provides migration instructions for `gz` library developers to
replace the `gz-common` plugin framework with the `gz-plugin`
framework. Some of the instructions here may also be useful to new adopters of
`gz-plugin`.

# Linking to ignition-plugin
# Linking to gz-plugin

`gz-plugin` has three components: `core`, `loader`, and `register`. Code that
just wants to use `PluginPtr` objects can link to `core`, e.g.:

```
target_link_libraries(my_target PUBLIC ignition-plugin2::core)
target_link_libraries(my_target PUBLIC gz-plugin2::core)
```

However, if your code wants to be able to load plugins, it should link to the
`loader` component. In most cases, it should probably link privately, unless you
need the `gz::plugin::Loader` class to be part of your library's API:

```
target_link_libraries(my_target PRIVATE ignition-plugin2::loader)
target_link_libraries(my_target PRIVATE gz-plugin2::loader)
```

If `gz::plugin::PluginPtr` objects are part of your library's API, then
Expand All @@ -28,9 +28,9 @@ you may want `loader` to be private while `core` is public:
```
target_link_libraries(my_target
PUBLIC
ignition-plugin2::core
gz-plugin2::core
PRIVATE
ignition-plugin2::loader
gz-plugin2::loader
)
```

Expand All @@ -39,14 +39,14 @@ then you should link against the `register` component. This should almost always
be a private link, since plugin registration is purely internal for a library:

```
target_link_libraries(my_plugin PRIVATE ignition-plugin2::register)
target_link_libraries(my_plugin PRIVATE gz-plugin2::register)
```

# Registering a plugin

The name of the header for registering plugins has changed:

* `<ignition/common/PluginMacros.hh>` should be replaced by `<ignition/plugin/Register.hh>`
* `<gz/common/PluginMacros.hh>` should be replaced by `<gz/plugin/Register.hh>`

The old `gz-common` plugin registration method had numerous macros for registering
plugins. Those have all been replaced with `GZ_ADD_PLUGIN`. Specifically:
Expand All @@ -68,9 +68,9 @@ simply need to make sure that the compiler can resolve the names of the classes
that you pass to it (and there will be a compilation error if it cannot).

It is now possible to register plugins across **multiple translation units**
within a single library. To do this, use `#include <ignition/plugin/Register.hh>`
within a single library. To do this, use `#include <gz/plugin/Register.hh>`
in **exactly one** of your library's translation units, and then use
`#include <ignition/plugin/RegisterMore.hh>` in all other translation units. It
`#include <gz/plugin/RegisterMore.hh>` in all other translation units. It
does not matter which translation unit you choose to be the "first", as long as
you choose exactly one.

Expand All @@ -84,7 +84,7 @@ then you should continue to use it. It does not have a replacement in `gz-plugin

Here is a list of things that you *should* replace:

* `#include <ignition/common/PluginLoader.hh>` should be replaced with `#include <ignition/plugin/Loader.hh>`
* `#include <gz/common/PluginLoader.hh>` should be replaced with `#include <gz/plugin/Loader.hh>`
* `gz::common::PluginLoader` should be replaced with `gz::plugin::Loader`
* When calling `Loader::Instantiate("....")` do **NOT** prefix the class name with `::`. E.g. `"::some_namespace::MyClass"` should now be `"some_namespace::MyClass"`.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Windows 7 | [![Build Status](https://build.osrfoundation.org/job/ignition_pl

** Library for registering plugin libraries and dynamically loading them at runtime.**

Gazebo Plugin is a component in the ignition framework, a set
Gazebo Plugin is a component in the Gazebo framework, a set
of libraries designed to rapidly develop robot applications.

[http://gazebosim.org](http://gazebosim.org)
Expand Down
4 changes: 2 additions & 2 deletions api.md.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Gazebo @IGN_DESIGNATION_CAP@
## Gazebo @GZ_DESIGNATION_CAP@

Gazebo @IGN_DESIGNATION_CAP@ is a component in Gazebo, a set of libraries
Gazebo @GZ_DESIGNATION_CAP@ is a component in Gazebo, a set of libraries
designed to rapidly develop robot and simulation applications.

## License
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:

install:
- vcpkg install dlfcn-win32
# ign-cmake
# gz-cmake
- git clone https://github.com/gazebosim/gz-cmake -b gz11
- cd gz-cmake
- md build
Expand Down
2 changes: 1 addition & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ gz_build_tests(


add_subdirectory(include/gz/plugin)
install(DIRECTORY include/ignition DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL})
Copy link
Member

Choose a reason for hiding this comment

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

I think this broke installation of the include/ignition redirect headers

install(DIRECTORY include/gz DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL})
8 changes: 4 additions & 4 deletions core/include/gz/plugin/detail/SpecializedPlugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// This preprocessor token should only be used by the unittest that is
// responsible for checking that the specialized routines are being used to
// access specialized plugin interfaces.
#ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
#ifdef GZ_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
bool usedSpecializedInterfaceAccess;
#endif

Expand Down Expand Up @@ -105,7 +105,7 @@ namespace gz
SpecInterface *SpecializedPlugin<SpecInterface>::PrivateQueryInterface(
type<SpecInterface>)
{
#ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
#ifdef GZ_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
usedSpecializedInterfaceAccess = true;
#endif
return static_cast<SpecInterface*>(
Expand All @@ -126,7 +126,7 @@ namespace gz
const SpecInterface *SpecializedPlugin<SpecInterface>::
PrivateQueryInterface(type<SpecInterface>) const
{
#ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
#ifdef GZ_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
usedSpecializedInterfaceAccess = true;
#endif
return static_cast<SpecInterface*>(
Expand All @@ -147,7 +147,7 @@ namespace gz
bool SpecializedPlugin<SpecInterface>::PrivateHasInterface(
type<SpecInterface>) const
{
#ifdef IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
#ifdef GZ_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
usedSpecializedInterfaceAccess = true;
#endif
return (nullptr != this->privateSpecializedInterfaceIterator->second);
Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ foreach(example_file ${example_files})
# to set it for all the examples.
target_compile_definitions(${example}
PRIVATE
"IGN_PLUGIN_EXAMPLES_LIBDIR=\"${PLUGIN_LIBDIR}\"")
"GZ_PLUGIN_EXAMPLES_LIBDIR=\"${PLUGIN_LIBDIR}\"")

if(Boost_PROGRAM_OPTIONS_FOUND)
target_link_libraries(${example} PRIVATE ${Boost_PROGRAM_OPTIONS_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion examples/integrators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using ODESystemFactory = gz::plugin::examples::ODESystemFactory;

// The macro that this uses is provided as a compile definition in the
// examples/CMakeLists.txt file.
const std::string PluginLibDir = IGN_PLUGIN_EXAMPLES_LIBDIR;
const std::string PluginLibDir = GZ_PLUGIN_EXAMPLES_LIBDIR;

/// \brief Return structure for numerical integration test results. If the name
/// is blank, that means the test was not run.
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins/RungeKutta4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Integrator : public gz::plugin::examples::NumericalIntegrator
const State &yn = _state;

// TODO: If we ever start to leverage Eigen or another linear algebra
// library besides ign-math, then clean up these expressions.
// library besides gz-math, then clean up these expressions.
const Derivative &k1 = function(tn, yn);
const Derivative &k2 = function(tn + h/2.0, add(yn, times(h/2.0, k1)));
const Derivative &k3 = function(tn + h/2.0, add(yn, times(h/2.0, k2)));
Expand Down
2 changes: 1 addition & 1 deletion examples/robot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace bpo = boost::program_options;
/////////////////////////////////////////////////
// The macro that this uses is provided as a compile definition in the
// examples/CMakeLists.txt file.
const std::string PluginLibDir = IGN_PLUGIN_EXAMPLES_LIBDIR;
const std::string PluginLibDir = GZ_PLUGIN_EXAMPLES_LIBDIR;

/////////////////////////////////////////////////
using namespace gz::plugin::examples;
Expand Down
2 changes: 1 addition & 1 deletion loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endif()

install(
DIRECTORY include/
DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL})
DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL})

#============================================================================
# gz command line support
Expand Down
18 changes: 9 additions & 9 deletions loader/conf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Used only for internal testing.
set(gz_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(gz_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/cmd${GZ_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: plugin2.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured" @ONLY)
"${GZ_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${GZ_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")
OUTPUT "${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured")

# Used for the installed version.
set(gz_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/gz/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(gz_library_path "${CMAKE_INSTALL_PREFIX}/lib/ruby/gz/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}")

# Generate the configuration file that is installed.
# Note that the major version of the library is included in the name.
# Ex: plugin2.yaml
configure_file(
"${IGN_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)
"${GZ_DESIGNATION}.yaml.in"
"${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml" @ONLY)

# Install the yaml configuration files in an unversioned location.
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/gz/)
14 changes: 7 additions & 7 deletions loader/src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target_link_libraries(${plugin_executable}
${loader}
)

set(EXE_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}/gz/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(EXE_INSTALL_DIR "${CMAKE_INSTALL_LIBEXECDIR}/gz/${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}")

install(
TARGETS
Expand All @@ -25,15 +25,15 @@ install(
# Generate the ruby script for internal testing.
# Note that the major version of the library is included in the name.
# Ex: cmdplugin2.rb
set(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/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(cmd_script_generated_test "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured_test "${CMAKE_CURRENT_BINARY_DIR}/test_cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb.configured")

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

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
"cmd${GZ_DESIGNATION}.rb.in"
"${cmd_script_configured_test}"
@ONLY)

Expand All @@ -47,15 +47,15 @@ file(GENERATE
# Generate the ruby script that gets installed.
# Note that the major version of the library is included in the name.
# Ex: cmdplugin2.rb
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured "${CMAKE_CURRENT_BINARY_DIR}/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb.configured")
set(cmd_script_generated "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb")
set(cmd_script_configured "${CMAKE_CURRENT_BINARY_DIR}/cmd${GZ_DESIGNATION}${PROJECT_VERSION_MAJOR}.rb.configured")

# Set the library_location variable to the relative path to the library file
# within the install directory structure.
set(plugin_exe_location "../../../${EXE_INSTALL_DIR}/$<TARGET_FILE_NAME:${plugin_executable}>")

configure_file(
"cmd${IGN_DESIGNATION}.rb.in"
"cmd${GZ_DESIGNATION}.rb.in"
"${cmd_script_configured}"
@ONLY)

Expand Down
2 changes: 1 addition & 1 deletion loader/src/cmd/cmdplugin.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COMMANDS = {
}

#
# Class for the Ignition @IGN_DESIGNATION@ command line tools.
# Class for the Gazebo @GZ_DESIGNATION@ command line tools.
#
class Cmd
def execute(args)
Expand Down
4 changes: 2 additions & 2 deletions loader/src/cmd/gz.hh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*
*/

#ifndef GZ_PLUGIN_IGN_HH_
#define GZ_PLUGIN_IGN_HH_
#ifndef GZ_PLUGIN_GZ_HH_
#define GZ_PLUGIN_GZ_HH_

#include "gz/plugin/Export.hh"

Expand Down
2 changes: 1 addition & 1 deletion loader/src/cmd/plugin_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ int main(int argc, char** argv)

addPluginFlags(app);

app.formatter(std::make_shared<IgnitionFormatter>(&app));
app.formatter(std::make_shared<GzFormatter>(&app));
chapulina marked this conversation as resolved.
Show resolved Hide resolved
CLI11_PARSE(app, argc, argv);
}
2 changes: 1 addition & 1 deletion register/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ gz_add_component(register INTERFACE)

install(
DIRECTORY include/
DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL})
DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL})
2 changes: 1 addition & 1 deletion register/include/gz/plugin/detail/Register.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extern "C"
/// \param[out] _outputAllInfo
/// Loader will pass in a pointer to a pointer of an InfoMap pertaining to
/// the highest API version that it knows of. If this GzPluginHook was
/// built against a version of ign-plugin that provides an equal or greater
/// built against a version of gz-plugin that provides an equal or greater
/// API version, then GzPluginHook will modify *_outputAllInfo to
/// point at its internal &InfoMap that corresponds to the requested API
/// version, which is identified by _inputAndOutputAPIVersion.
Expand Down
4 changes: 2 additions & 2 deletions test/integration/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*
*/

// Defining this macro before including ignition/plugin/SpecializedPluginPtr.hh
// Defining this macro before including gz/plugin/SpecializedPluginPtr.hh
// allows us to test that the high-speed routines are being used to access the
// specialized plugin interfaces.
#define IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
#define GZ_UNITTEST_SPECIALIZED_PLUGIN_ACCESS

#include <gtest/gtest.h>
#include <string>
Expand Down
4 changes: 2 additions & 2 deletions test/integration/templated_plugins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*
*/

// Defining this macro before including ignition/plugin/SpecializedPluginPtr.hh
// Defining this macro before including gz/plugin/SpecializedPluginPtr.hh
// allows us to test that the high-speed routines are being used to access the
// specialized plugin interfaces.
#define IGNITION_UNITTEST_SPECIALIZED_PLUGIN_ACCESS
#define GZ_UNITTEST_SPECIALIZED_PLUGIN_ACCESS

#include <gtest/gtest.h>

Expand Down
2 changes: 1 addition & 1 deletion test/performance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gz_get_sources(tests)

# plugin_specialization test causes lcov to hang
# see ign-cmake issue 25
# see gz-cmake issue 25
if("${CMAKE_BUILD_TYPE_UPPERCASE}" STREQUAL "COVERAGE")
list(REMOVE_ITEM tests
plugin_specialization.cc)
Expand Down
4 changes: 2 additions & 2 deletions tutorials.md.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
\page tutorials Tutorials

Welcome to the Gazebo @IGN_DESIGNATION_CAP@ tutorials. These tutorials
Welcome to the Gazebo @GZ_DESIGNATION_CAP@ tutorials. These tutorials
will guide you through the process of understanding the capabilities of the
Gazebo @IGN_DESIGNATION_CAP@ library and how to use the library effectively.
Gazebo @GZ_DESIGNATION_CAP@ library and how to use the library effectively.


**Contents**
Expand Down
Loading