Skip to content

Commit

Permalink
ign -> gz Environment Variable Migration (#259)
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon authored Jun 8, 2022
1 parent 0522d08 commit 422a18f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ release will remove the deprecated code.
Use `gz/...` instead.
3. Protobuf messages and packages will no longer use `ignition.msgs`, use `gz.msgs` instead
4. `INSTALL_IGN_MSGS_GEN_EXECUTABLE` and `IGN_MSGS_GEN_EXECUTABLE` are deprecated and will be removed. Use `INSTALL_GZ_MSGS_GEN_EXECUTABLE` and `GZ_MSGS_GEN_EXECUTABLE` instead.
5. `IGN_DESCRIPTOR_PATH` is deprecated and will be removed. Use `GZ_DESCRIPTOR_PATH` instead.

## Gazebo Msgs 8.1 to 8.2

Expand Down
2 changes: 1 addition & 1 deletion include/gz/msgs/Factory.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace gz
/// \class Factory Factory.hh gz/msgs.hh
/// \brief A factory that generates protobuf message based on a string type.
/// This class will also try to load all Protobuf descriptors specified
/// in the IGN_DESCRIPTOR_PATH environment variable on program start.
/// in the GZ_DESCRIPTOR_PATH environment variable on program start.
class GZ_MSGS_VISIBLE Factory
{
/// \brief Register a message.
Expand Down
28 changes: 21 additions & 7 deletions src/Factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,38 @@ std::vector<std::string> split(const std::string &_orig, char _delim)
/////////////////////////////////////////////////
/// \brief A factory class to generate protobuf messages at runtime based on
/// their message descriptors. The location of the .desc files is expected
/// via the IGN_DESCRIPTOR_PATH environment variable. This environment
/// via the GZ_DESCRIPTOR_PATH environment variable. This environment
/// variable expects paths to directories containing .desc files.
/// Any file without the .desc extension will be ignored.
class DynamicFactory
{
//////////////////////////////////////////////////
/// \brief Constructor.
/// The constructor will try to load all descriptors specified in the
/// IGN_DESCRIPTOR_PATH environment variable.
/// GZ_DESCRIPTOR_PATH environment variable.
public: DynamicFactory()
{
// Try to get the list of paths from an environment variable.
const char *ignDescPaths = std::getenv("IGN_DESCRIPTOR_PATH");
if (!ignDescPaths)
return;
const char *descPaths = std::getenv("GZ_DESCRIPTOR_PATH");
if (!descPaths)
{
// TODO(CH3): Deprecated. Remove on tock.
// Remember to still return !!
descPaths = std::getenv("IGN_DESCRIPTOR_PATH");

if (!descPaths)
{
return;
}
else
{
std::cerr << "IGN_DESCRIPTOR_PATH is deprecated and will be removed! "
<< "Use GZ_DESCRIPTOR_PATH instead!" << std::endl;
}
}

// Load all the descriptors found in the paths set with IGN_DESCRIPTOR_PATH.
this->LoadDescriptors(ignDescPaths);
// Load all the descriptors found in the paths set with GZ_DESCRIPTOR_PATH.
this->LoadDescriptors(descPaths);
}

//////////////////////////////////////////////////
Expand Down

0 comments on commit 422a18f

Please sign in to comment.