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 CLI Migration : gz-plugin #88

Merged
merged 3 commits into from
Jun 21, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gz_find_package(DL

#--------------------------------------
# Find ignition-tools
find_program(GZ_TOOLS_PROGRAM ign)
find_program(GZ_TOOLS_PROGRAM gz)


#--------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* [Pull request #52](https://github.com/gazebosim/gz-plugin/pull/52)
* [Pull request #51](https://github.com/gazebosim/gz-plugin/pull/51)

1. Find ign program instead of ignition-tools
1. Find gz program instead of ignition-tools
* [Pull request #57](https://github.com/gazebosim/gz-plugin/pull/57)

1. Remove ign-tools from CMakeLists.txt. Not used
Expand All @@ -37,7 +37,7 @@
1. Fix downstream Windows builds
* [Pull request #38](https://github.com/gazebosim/gz-plugin/pull/38)

1. Add `ign plugin --info` to print plugin info
1. Add `gz plugin --info` to print plugin info
* [Pull request #32](https://github.com/gazebosim/gz-plugin/pull/32)

1. Add Windows installation
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ of libraries designed to rapidly develop robot applications.
* Querying of interfaces **by C++ type or name string**.
* **Dynamically load** plugins at runtime according to the interfaces they provide.
* **Reference counting** of plugin objects to unload libraries no longer in use.
* **Command line tool** `ign plugin` to inspect plugins.
* **Command line tool** `gz plugin` to inspect plugins.

## Installation

Expand Down
10 changes: 5 additions & 5 deletions loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# "tests" variable
gz_get_libsources_and_unittests(sources tests)

# Disable ign_TEST if ignition-tools is not found
# Disable gz_TEST if ignition-tools is not found
if (MSVC OR NOT GZ_TOOLS_PROGRAM)
list(REMOVE_ITEM tests src/ign_TEST.cc)
list(REMOVE_ITEM tests src/gz_TEST.cc)
endif()

# Create the library target
Expand Down Expand Up @@ -40,11 +40,11 @@ foreach(test ${test_targets})

endforeach()

if(TARGET UNIT_ign_TEST)
if(TARGET UNIT_gz_TEST)
set(_env_vars)
list(APPEND _env_vars "GZ_CONFIG_PATH=${CMAKE_BINARY_DIR}/test/conf/$<CONFIG>")

set_tests_properties(UNIT_ign_TEST PROPERTIES
set_tests_properties(UNIT_gz_TEST PROPERTIES
ENVIRONMENT "${_env_vars}")
endif()

Expand All @@ -53,7 +53,7 @@ install(
DESTINATION ${IGN_INCLUDE_INSTALL_DIR_FULL})

#============================================================================
# ign command line support
# gz command line support
#============================================================================
add_subdirectory(conf)
add_subdirectory(src)
4 changes: 2 additions & 2 deletions loader/conf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Used only for internal testing.
set(gz_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}")
set(gz_library_path "${CMAKE_BINARY_DIR}/test/lib/$<CONFIG>/ruby/gz/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.
Expand All @@ -13,7 +13,7 @@ file(GENERATE
INPUT "${CMAKE_CURRENT_BINARY_DIR}/${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.yaml.configured")

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

# Generate the configuration file that is installed.
# Note that the major version of the library is included in the name.
Expand Down
12 changes: 6 additions & 6 deletions loader/src/cmd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
add_library(ign STATIC ign.cc)
target_include_directories(ign PUBLIC ${CMAKE_SOURCE_DIR}/loader/include)
target_link_libraries(ign PUBLIC
add_library(gz STATIC gz.cc)
target_include_directories(gz PUBLIC ${CMAKE_SOURCE_DIR}/loader/include)
target_link_libraries(gz PUBLIC
${PROJECT_LIBRARY_TARGET_NAME}
)

set(plugin_executable ign-plugin)
add_executable(${plugin_executable} plugin_main.cc)
target_link_libraries(${plugin_executable}
ign
gz
ignition-utils${IGN_UTILS_VER}::cli
${loader}
)
Expand All @@ -25,7 +25,7 @@ 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/ignition/cmd${IGN_DESIGNATION}${PROJECT_VERSION_MAJOR}.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 the library_location variable to the full path of the library file within
Expand Down Expand Up @@ -64,4 +64,4 @@ file(GENERATE
INPUT "${cmd_script_configured}")

# Install the ruby command line library in an unversioned location.
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/ignition)
install(FILES ${cmd_script_generated} DESTINATION lib/ruby/gz)
2 changes: 1 addition & 1 deletion loader/src/cmd/ign.cc → loader/src/cmd/gz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "gz/plugin/Loader.hh"
#include "gz/plugin/config.hh"
#include "ign.hh"
#include "gz.hh"

//////////////////////////////////////////////////
extern "C" void cmdPluginInfo(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion loader/src/cmd/plugin_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
#include <gz/utils/cli/CLI.hpp>

#include "ign.hh"
#include "gz.hh"

//////////////////////////////////////////////////
/// \brief Enumeration of available commands
Expand Down
64 changes: 32 additions & 32 deletions loader/src/ign_TEST.cc → loader/src/gz_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

using namespace gz;

static const std::string g_ignVersion("--force-version " + // NOLINT(*)
static const std::string g_gzVersion("--force-version " + // NOLINT(*)
std::string(GZ_VERSION_FULL));

/////////////////////////////////////////////////
Expand All @@ -54,20 +54,20 @@ std::string custom_exec_str(std::string _cmd)
}

//////////////////////////////////////////////////
/// \brief Check 'ign plugin --help'.
TEST(ignTest, IgnPluginHelp)
/// \brief Check 'gz plugin --help'.
TEST(gzTest, IgnPluginHelp)
{
// Path to ign executable
std::string ign = std::string(GZ_PATH);
std::string output = custom_exec_str(ign + " plugin --help");
// Path to gz executable
std::string gz = std::string(GZ_PATH);
std::string output = custom_exec_str(gz + " plugin --help");
EXPECT_NE(std::string::npos,
output.find("-i,--info Get info about a plugin."))
<< output;
EXPECT_NE(std::string::npos,
output.find("-p,--plugin TEXT Needs: --info"))
<< output;

output = custom_exec_str(ign + " plugin");
output = custom_exec_str(gz + " plugin");
EXPECT_NE(std::string::npos,
output.find("-i,--info Get info about a plugin."))
<< output;
Expand All @@ -77,13 +77,13 @@ TEST(ignTest, IgnPluginHelp)
}

//////////////////////////////////////////////////
/// \brief Check 'ign plugin --info' for a non-existent file.
TEST(ignTest, PluginInfoNonexistentLibrary)
/// \brief Check 'gz plugin --info' for a non-existent file.
TEST(gzTest, PluginInfoNonexistentLibrary)
{
// Path to ign executable
std::string ign = std::string(GZ_PATH);
// Path to gz executable
std::string gz = std::string(GZ_PATH);

std::string output = custom_exec_str(ign + " plugin --info --plugin " +
std::string output = custom_exec_str(gz + " plugin --info --plugin " +
"/path/to/libDoesNotExist.so");

EXPECT_NE(std::string::npos, output.find("Error while loading the library"))
Expand All @@ -95,13 +95,13 @@ TEST(ignTest, PluginInfoNonexistentLibrary)
}

//////////////////////////////////////////////////
/// \brief Check 'ign plugin --info' for a file that isn't a shared library.
TEST(ignTest, PluginInfoNonLibrary)
/// \brief Check 'gz plugin --info' for a file that isn't a shared library.
TEST(gzTest, PluginInfoNonLibrary)
{
// Path to ign executable
std::string ign = std::string(GZ_PATH);
// Path to gz executable
std::string gz = std::string(GZ_PATH);

std::string output = custom_exec_str(ign + " plugin --info --plugin " +
std::string output = custom_exec_str(gz + " plugin --info --plugin " +
std::string(GZ_PLUGIN_SOURCE_DIR) + "/core/src/Plugin.cc");

EXPECT_NE(std::string::npos, output.find("Error while loading the library"))
Expand All @@ -113,13 +113,13 @@ TEST(ignTest, PluginInfoNonLibrary)
}

//////////////////////////////////////////////////
/// \brief Check 'ign plugin --info' for a library that has no plugins.
TEST(ignTest, PluginInfoNonPluginLibrary)
/// \brief Check 'gz plugin --info' for a library that has no plugins.
TEST(gzTest, PluginInfoNonPluginLibrary)
{
// Path to ign executable
std::string ign = std::string(GZ_PATH);
// Path to gz executable
std::string gz = std::string(GZ_PATH);

std::string output = custom_exec_str(ign + " plugin --info --plugin " +
std::string output = custom_exec_str(gz + " plugin --info --plugin " +
GZ_PLUGIN_LIB);

EXPECT_NE(std::string::npos, output.find("does not export any plugins. The "
Expand All @@ -132,13 +132,13 @@ TEST(ignTest, PluginInfoNonPluginLibrary)
}

//////////////////////////////////////////////////
/// \brief Check 'ign plugin --info' for a library with plugins.
TEST(ignTest, PluginInfoDummyPlugins)
/// \brief Check 'gz plugin --info' for a library with plugins.
TEST(gzTest, PluginInfoDummyPlugins)
{
// Path to ign executable
std::string ign = std::string(GZ_PATH);
// Path to gz executable
std::string gz = std::string(GZ_PATH);

std::string output = custom_exec_str(ign + " plugin --info --plugin " +
std::string output = custom_exec_str(gz + " plugin --info --plugin " +
GzDummyPlugins_LIB);

EXPECT_NE(std::string::npos, output.find("Found 3 plugins in library file"))
Expand Down Expand Up @@ -171,13 +171,13 @@ TEST(ignTest, PluginInfoDummyPlugins)
}

//////////////////////////////////////////////////
/// \brief Check 'ign plugin --info' with verbose output.
TEST(ignTest, PluginInfoVerboseDummyPlugins)
/// \brief Check 'gz plugin --info' with verbose output.
TEST(gzTest, PluginInfoVerboseDummyPlugins)
{
// Path to ign executable
std::string ign = std::string(GZ_PATH);
// Path to gz executable
std::string gz = std::string(GZ_PATH);

std::string output = custom_exec_str(ign + " plugin --info --plugin " +
std::string output = custom_exec_str(gz + " plugin --info --plugin " +
GzDummyPlugins_LIB + " --verbose");

EXPECT_NE(std::string::npos, output.find("Known Interfaces: 7"))
Expand Down
6 changes: 3 additions & 3 deletions tutorials/02_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sudo apt install libignition-plugin2-dev
sudo apt-get install libignition-cmake3-dev libignition-tools2-dev libignition-utils2-cli-dev
```

1. Install Gazebo Tools if you want to use the `ign plugin` command line tool:
1. Install Gazebo Tools if you want to use the `gz plugin` command line tool:
```bash
sudo apt-get install ignition-tools2

Expand Down Expand Up @@ -128,8 +128,8 @@ Navigate to `condabin` if necessary to use the `conda` command (i.e., if Conda i

Create if necessary, and activate a Conda environment:
```bash
conda create -n ign-ws
conda activate ign-ws
conda create -n gz-ws
conda activate gz-ws
```

## Binary Installation
Expand Down