Skip to content

Commit

Permalink
Add environment variable to locate plugins (#104)
Browse files Browse the repository at this point in the history
* Add environment variable to locate plugins

I just copied how this was done in Ignition GUI

Signed-off-by: Levi Armstrong <[email protected]>

* Add check for environment variable for ogre resource path

Signed-off-by: Levi Armstrong <[email protected]>

* Add check for environment variable for ogre2 resource path

Signed-off-by: Levi Armstrong <[email protected]>
  • Loading branch information
Levi-Armstrong authored Jul 10, 2020
1 parent e445c9b commit 6338cdb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion ogre/src/OgreRenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ RenderEngine *OgreRenderEnginePlugin::Engine() const
OgreRenderEngine::OgreRenderEngine() :
dataPtr(new OgreRenderEnginePrivate)
{
this->ogrePaths.push_back(std::string(OGRE_RESOURCE_PATH));
this->ogrePaths.push_back(OGRE_RESOURCE_PATH);

const char *env = std::getenv("OGRE_RESOURCE_PATH");
if(env)
this->ogrePaths.push_back(std::string(env));
}

//////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ Ogre2RenderEngine::Ogre2RenderEngine() :
std::string ogrePath = std::string(OGRE2_RESOURCE_PATH);
this->ogrePaths.push_back(ogrePath);

const char *env = std::getenv("OGRE2_RESOURCE_PATH");
if(env)
this->ogrePaths.push_back(std::string(env));

#ifdef __APPLE__
// on OSX the plugins may be placed in the parent lib directory
if (ogrePath.rfind("OGRE") == ogrePath.size()-4u)
Expand Down
6 changes: 5 additions & 1 deletion src/RenderEngineManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class ignition::rendering::RenderEngineManagerPrivate

/// \brief Plugin loader for managing render engine plugin libraries
public: ignition::plugin::Loader pluginLoader;

/// \brief Environment variable which holds paths to look for plugins
public: std::string pluginPathEnv = "IGN_RENDERING_PLUGIN_PATH";

/// \brief Mutex to protect the engines map.
public: std::recursive_mutex enginesMutex;
Expand Down Expand Up @@ -373,7 +376,8 @@ bool RenderEngineManagerPrivate::LoadEnginePlugin(
ignmsg << "Loading plugin [" << _filename << "]" << std::endl;

ignition::common::SystemPaths systemPaths;

systemPaths.SetPluginPathEnv(this->pluginPathEnv);

// Add default install folder.
systemPaths.AddPluginPaths(std::string(IGN_RENDERING_PLUGIN_PATH));
// Add extra search path.
Expand Down

0 comments on commit 6338cdb

Please sign in to comment.