Skip to content

Commit

Permalink
plugins: look for HPP_PLUGIN_DIRS
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Sep 5, 2024
1 parent d42bbbc commit 7b76c70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/hpp/core/plugin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ class ProblemSolverPlugin {
namespace plugin {
/// Find the absolute path to a library named name.
/// \param name
/// \return name if it is an absolute path. Otherwise, for each path in
/// LD_LIBRARY_PATH environment variable, look for path/hppPlugins/name.
/// \return name if it is an absolute path.
/// Otherwise, for each path in HPP_PLUGIN_DIRS environment variable,
/// look for path/hppPlugins/name.
/// Otherwise, for each path in LD_LIBRARY_PATH environment variable,
/// look for path/hppPlugins/name.
/// \throw std::invalid_argument if not valid file found.
std::string findPluginLibrary(const std::string& name);

Expand Down
9 changes: 9 additions & 0 deletions src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ namespace core {
namespace plugin {
std::string findPluginLibrary(const std::string& name) {
if (fs::path(name).is_absolute()) return name;
std::vector<std::string> ppaths =
::pinocchio::extractPathFromEnvVar("HPP_PLUGIN_DIRS", ":");
for (std::size_t i = 0; i < ppaths.size(); ++i) {
fs::path lib(ppaths[i]);
lib /= "hppPlugins";
lib /= name;
if (fs::is_regular_file(lib)) return lib.native();
}

std::vector<std::string> ldpaths =
::pinocchio::extractPathFromEnvVar("LD_LIBRARY_PATH", ":");
for (std::size_t i = 0; i < ldpaths.size(); ++i) {
Expand Down

0 comments on commit 7b76c70

Please sign in to comment.