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 Macro Migration : gz-fuel-tools #259

Merged
merged 10 commits into from
Jun 18, 2022
6 changes: 5 additions & 1 deletion Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
* **Replacement**: `gz` namespace
* **Deprecation**: `ignition/...` headers
* **Replacement**: `gz/...` headers
* The following `ign_` prefixed macros are deprecated and will be removed in future versions.
Additionally, they will only be available when including the corresponding `ignition/...` header.
Use the `gz_` prefix instead.
* `ign_strcat`, `ign_strcpy`, `ign_sprintf`, `ign_strdup`


## Gazebo Fuel Tools 5.X to 6.X

Expand Down Expand Up @@ -101,4 +106,3 @@
└── modelname
├── 1
└── 2

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ sudo apt install ruby-ffi libzip-dev libcurl-dev libjsoncpp-dev
* Think about how to detect when new versions of remote models have been uploaded.
* Idea of a hash.

* Add ignition fuel command line utilities for:
* Add Gazebo Fuel command line utilities for:
* detail
* create
* delete
Expand Down
2 changes: 1 addition & 1 deletion conf/fuel.yaml.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
--- # Subcommands available inside ignition fuel
--- # Subcommands available inside Gazebo Fuel
format: 1.0.0
library_name: @PROJECT_NAME_NO_VERSION@
library_version: @PROJECT_VERSION_FULL@
Expand Down
2 changes: 1 addition & 1 deletion include/gz/fuel_tools/ClientConfig.hh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace gz
private: std::unique_ptr<ServerConfigPrivate> dataPtr;
};

/// \brief High level interface to ignition fuel.
/// \brief High level interface to Gazebo Fuel.
///
class GZ_FUEL_TOOLS_VISIBLE ClientConfig
{
Expand Down
16 changes: 8 additions & 8 deletions include/gz/fuel_tools/FuelClient.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace gz
class ModelIdentifier;
class ServerConfig;

/// \brief High level interface to ignition fuel
/// \brief High level interface to Gazebo Fuel
class GZ_FUEL_TOOLS_VISIBLE FuelClient
{
/// \brief Default constructor.
Expand Down Expand Up @@ -201,21 +201,21 @@ namespace gz
public: Result DeleteUrl(const gz::common::URI &_uri,
const std::vector<std::string> &_headers);

/// \brief Download a model from ignition fuel. This will override an
/// \brief Download a model from Gazebo Fuel. This will override an
/// existing local copy of the model.
/// \param[in] _id The model identifier.
/// \return Result of the download operation
public: Result DownloadModel(const ModelIdentifier &_id);

/// \brief Download a model from ignition fuel. This will override an
/// \brief Download a model from Gazebo Fuel. This will override an
/// existing local copy of the model.
/// \param[in] _id The model identifier.
/// \param[in] _headers Headers to set on the HTTP request.
/// \return Result of the download operation
public: Result DownloadModel(const ModelIdentifier &_id,
const std::vector<std::string> &_headers);

/// \brief Download a model from ignition fuel. This will override an
/// \brief Download a model from Gazebo Fuel. This will override an
/// existing local copy of the model.
/// \param[in] _id The model identifier.
/// \param[in] _headers Headers to set on the HTTP request.
Expand Down Expand Up @@ -254,7 +254,7 @@ namespace gz
public: Result DownloadWorld(WorldIdentifier &_id,
const std::vector<std::string> &_headers);

/// \brief Download a model from ignition fuel. This will override an
/// \brief Download a model from Gazebo Fuel. This will override an
/// existing local copy of the model.
/// \param[in] _modelUrl The unique URL of the model to download.
/// E.g.: https://fuel.ignitionrobotics.org/1.0/caguero/models/Beer
Expand All @@ -263,7 +263,7 @@ namespace gz
public: Result DownloadModel(const common::URI &_modelUrl,
std::string &_path);

/// \brief Download a world from ignition fuel. This will override an
/// \brief Download a world from Gazebo Fuel. This will override an
/// existing local copy of the world.
/// \param[in] _worldUrl The unique URL of the world to download.
/// E.g.: https://fuel.ignitionrobotics.org/1.0/OpenRobotics/worlds/Empty
Expand All @@ -274,7 +274,7 @@ namespace gz

using ModelResult = std::tuple<ModelIdentifier, Result>;

/// \brief Download a list of models from ignition fuel.
/// \brief Download a list of models from Gazebo Fuel.
/// \param[in] _ids The list of model ids to download.
/// This will also find all recursive dependencies of the models
/// \param[in] _jobs Number of parallel jobs to use to download models
Expand All @@ -286,7 +286,7 @@ namespace gz
const std::vector<ModelIdentifier> &_ids,
size_t _jobs = 2);

/// \brief Download a list of mworlds from ignition fuel.
/// \brief Download a list of mworlds from Gazebo Fuel.
/// \param[in] _ids The list of world ids to download.
/// \param[in] _jobs Number of parallel jobs to use to download worlds.
/// \return Result of the download operation.
Expand Down
17 changes: 8 additions & 9 deletions include/gz/fuel_tools/Helpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@

// Use safer functions on Windows
#ifdef _MSC_VER
#define ign_strcat strcat_s
#define ign_strcpy strcpy_s
#define ign_sprintf sprintf_s
#define ign_strdup _strdup
#define gz_strcat strcat_s
#define gz_strcpy strcpy_s
#define gz_sprintf sprintf_s
#define gz_strdup _strdup
#else
#define ign_strcat std::strcat
#define ign_strcpy std::strcpy
#define ign_sprintf std::sprintf
#define ign_strdup strdup
#define gz_strcat std::strcat
#define gz_strcpy std::strcpy
#define gz_sprintf std::sprintf
#define gz_strdup strdup
#endif

namespace gz
Expand All @@ -50,4 +50,3 @@ std::string uriToPath(const gz::common::URI &_uri);

// IGNITION_FUEL_TOOLS_HELPERS_HH_
#endif

2 changes: 1 addition & 1 deletion include/gz/fuel_tools/Interface.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace gz
namespace fuel_tools
{
/// \brief Download the specified resource into the default configuration of
/// fuel tools. This will place the asset in ~/.ignition/fuel.
/// fuel tools. This will place the asset in ~/.gz/fuel.
/// \param[in] _uri URI to the asset.
/// \return Path to the downloaded asset. Empty on error.
GZ_FUEL_TOOLS_VISIBLE std::string fetchResource(
Expand Down
5 changes: 5 additions & 0 deletions include/ignition/fuel_tools/Helpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@

#include <gz/fuel_tools/Helpers.hh>
#include <ignition/fuel_tools/config.hh>

#define ign_strcat gz_strcat
#define ign_strcpy gz_strcpy
#define ign_sprintf gz_sprintf
#define ign_strdup gz_strdup
8 changes: 4 additions & 4 deletions src/ClientConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class gz::fuel_tools::ClientConfigPrivate
public: ClientConfigPrivate()
{
std::string homePath;
gz::common::env(IGN_HOMEDIR, homePath);
gz::common::env(GZ_HOMEDIR, homePath);
this->cacheLocation = common::joinPaths(
homePath, ".ignition", "fuel");

Expand Down Expand Up @@ -208,7 +208,7 @@ ClientConfig::ClientConfig() : dataPtr(new ClientConfigPrivate)
if (gz::common::env("IGN_FUEL_CACHE_PATH", gzFuelPath))
{
gzwarn << "Using deprecated environment variable [IGN_FUEL_CACHE_PATH] "
<< "set cache path. Please use [GZ_FUEL_CACHE_PATH] instead."
<< "to set cache path. Please use [GZ_FUEL_CACHE_PATH] instead."
<< std::endl;
}
else
Expand Down Expand Up @@ -426,7 +426,7 @@ bool ClientConfig::LoadConfig(const std::string &_file)

// Default cache path.
std::string homePath;
gz::common::env(IGN_HOMEDIR, homePath);
gz::common::env(GZ_HOMEDIR, homePath);
std::string cacheLocation = gz::common::joinPaths(
homePath, ".ignition", "fuel");

Expand All @@ -446,7 +446,7 @@ bool ClientConfig::LoadConfig(const std::string &_file)
else if (gz::common::env("IGN_FUEL_CACHE_PATH", gzFuelPath))
{
gzwarn << "Using deprecated environment variable [IGN_FUEL_CACHE_PATH] "
<< "set cache path. Please use [GZ_FUEL_CACHE_PATH] instead."
<< "to set cache path. Please use [GZ_FUEL_CACHE_PATH] instead."
<< std::endl;

gzwarn << "GZ_FUEL_CACHE_PATH is set to [" << gzFuelPath << "]. The "
Expand Down
2 changes: 1 addition & 1 deletion src/FuelClient_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ TEST_F(FuelClientTest, DownloadModel)
/////////////////////////////////////////////////
// Windows doesn't support colons in filenames
// https://github.com/gazebosim/gz-fuel-tools/issues/106
TEST_F(FuelClientTest, IGN_UTILS_TEST_DISABLED_ON_WIN32(ModelDependencies))
TEST_F(FuelClientTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ModelDependencies))
{
// Configure to use binary path as cache
ASSERT_EQ(0, ChangeDirectory(PROJECT_BINARY_PATH));
Expand Down
8 changes: 4 additions & 4 deletions src/cmd/cmdfuel.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ class Cmd
end

# Read the library version.
Importer.extern 'char* ignitionVersion()'
Importer.extern 'char* gzVersion()'
begin
plugin_version = Importer.ignitionVersion.to_s
plugin_version = Importer.gzVersion.to_s
rescue DLError
puts "Library error: Problem running 'ignitionVersion()' from #{plugin}."
exit(-1)
puts "Library error: Problem running 'gzVersion()' from #{plugin}."
exit(-1)
end

# Sanity check: Verify that the version of the yaml file matches the version
Expand Down
2 changes: 1 addition & 1 deletion src/ign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ extern "C" bool getOwnerWorlds(
}

//////////////////////////////////////////////////
extern "C" GZ_FUEL_TOOLS_VISIBLE char *ignitionVersion()
extern "C" GZ_FUEL_TOOLS_VISIBLE char *gzVersion()
{
return strdup(GZ_FUEL_TOOLS_VERSION_FULL);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ign.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/// \brief External hook to read the library version.
/// \return C-string representing the version. Ex.: 0.1.2
extern "C" GZ_FUEL_TOOLS_VISIBLE char *ignitionVersion();
extern "C" GZ_FUEL_TOOLS_VISIBLE char *gzVersion();

/// \brief Set verbosity level
/// \param[in] _verbosity 0 to 4
Expand Down
14 changes: 7 additions & 7 deletions src/ign_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ auto g_listCmd = "ign fuel list -v 4 --force-version " + g_version;

/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Versions))
TEST(CmdLine, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Versions))
{
auto output = custom_exec_str("ign fuel --versions");
EXPECT_NE(output.find(g_version), std::string::npos) << output;
}

/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Help))
TEST(CmdLine, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Help))
{
auto output = custom_exec_str("ign fuel --force-version " + g_version +
" --help");
Expand All @@ -76,7 +76,7 @@ TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Help))

/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ListFail))
TEST(CmdLine, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ListFail))
{
auto output = custom_exec_str(g_listCmd);
EXPECT_NE(output.find("Missing resource type"), std::string::npos) << output;
Expand All @@ -96,7 +96,7 @@ TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ListFail))
/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine,
IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ModelListConfigServerUgly))
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ModelListConfigServerUgly))
{
auto output = custom_exec_str(g_listCmd + " -t model --raw");
EXPECT_NE(output.find("https://fuel.ignitionrobotics.org/1.0/"),
Expand All @@ -107,7 +107,7 @@ TEST(CmdLine,
/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine,
IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ModelListCustomServerPretty))
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ModelListCustomServerPretty))
{
auto output = custom_exec_str(
g_listCmd + " -t model -u https://staging-fuel.ignitionrobotics.org");
Expand All @@ -125,7 +125,7 @@ TEST(CmdLine,

/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(WorldListConfigServerUgly))
TEST(CmdLine, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(WorldListConfigServerUgly))
{
auto output = custom_exec_str(g_listCmd +
" -t world --raw -u https://staging-fuel.ignitionrobotics.org");
Expand All @@ -137,7 +137,7 @@ TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(WorldListConfigServerUgly))
/////////////////////////////////////////////////
// https://github.com/gazebosim/gz-fuel-tools/issues/113
TEST(CmdLine,
IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(WorldListCustomServerPretty))
GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(WorldListCustomServerPretty))
{
auto output = custom_exec_str(
g_listCmd + " -t world -u https://staging-fuel.ignitionrobotics.org");
Expand Down
6 changes: 3 additions & 3 deletions test/test_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ namespace testing
PROCESS_INFORMATION processInfo;

char cmd[500];
ign_strcpy(cmd, _command);
ign_strcat(cmd, " ");
ign_strcat(cmd, _partition);
gz_strcpy(cmd, _command);
gz_strcat(cmd, " ");
gz_strcat(cmd, _partition);

if (!CreateProcess(NULL, const_cast<LPSTR>(cmd), NULL, NULL,
TRUE, 0, NULL, NULL, &info, &processInfo))
Expand Down