Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
fa43cfd7
Unverified
Commit
fa43cfd7
authored
Aug 03, 2019
by
peastman
Committed by
GitHub
Aug 03, 2019
Browse files
Merge pull request #2358 from tallakahath/master
Support for multiple paths in OPENMM_PLUGIN_DIR
parents
2ff59259
40a9d051
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
21 deletions
+37
-21
olla/include/openmm/Platform.h
olla/include/openmm/Platform.h
+9
-4
olla/src/Platform.cpp
olla/src/Platform.cpp
+28
-17
No files found.
olla/include/openmm/Platform.h
View file @
fa43cfd7
...
@@ -213,12 +213,17 @@ public:
...
@@ -213,12 +213,17 @@ public:
*/
*/
static
void
loadPluginLibrary
(
const
std
::
string
&
file
);
static
void
loadPluginLibrary
(
const
std
::
string
&
file
);
/**
/**
* Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from a single directory.
* Load multiple dynamic libraries (DLLs) which contain OpenMM plugins from one or more directories.
* This method loops over every file contained in the specified directory and calls loadPluginLibrary()
* Multiple fully-qualified paths can be joined together with ':' on unix-like systems
* (or ';' on windows-like systems); each will be searched for plugins, in-order. For example,
* '/foo/plugins:/bar/plugins' will search both `/foo/plugins` and `/bar/plugins`. If an
* identically-named plugin is encountered twice it will be loaded at both points; be careful!!!
*
* This method loops over every file contained in the specified directories and calls loadPluginLibrary()
* for each one. If an error occurs while trying to load a particular file, that file is simply
* for each one. If an error occurs while trying to load a particular file, that file is simply
* ignored. You can retrieve a list of all such errors by calling getPluginLoadFailures().
* ignored. You can retrieve a list of all such errors by calling getPluginLoadFailures().
*
*
* @param directory
the path to the directory
containing libraries to load
* @param directory
a ':' (unix) or ';' (windows) deliminated list of paths
containing libraries to load
* @return the names of all files which were successfully loaded as libraries
* @return the names of all files which were successfully loaded as libraries
*/
*/
static
std
::
vector
<
std
::
string
>
loadPluginsFromDirectory
(
const
std
::
string
&
directory
);
static
std
::
vector
<
std
::
string
>
loadPluginsFromDirectory
(
const
std
::
string
&
directory
);
...
...
olla/src/Platform.cpp
View file @
fa43cfd7
...
@@ -37,7 +37,6 @@
...
@@ -37,7 +37,6 @@
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#ifdef WIN32
#ifdef WIN32
#include <windows.h>
#include <windows.h>
#include <sstream>
#else
#else
#ifndef __PNACL__
#ifndef __PNACL__
#include <dlfcn.h>
#include <dlfcn.h>
...
@@ -45,6 +44,7 @@
...
@@ -45,6 +44,7 @@
#include <dirent.h>
#include <dirent.h>
#include <cstdlib>
#include <cstdlib>
#endif
#endif
#include <sstream>
#include <set>
#include <set>
#include <algorithm>
#include <algorithm>
...
@@ -261,31 +261,42 @@ void Platform::loadPluginLibrary(const string& file) {
...
@@ -261,31 +261,42 @@ void Platform::loadPluginLibrary(const string& file) {
vector
<
string
>
Platform
::
loadPluginsFromDirectory
(
const
string
&
directory
)
{
vector
<
string
>
Platform
::
loadPluginsFromDirectory
(
const
string
&
directory
)
{
vector
<
string
>
files
;
vector
<
string
>
files
;
char
dirSeparator
;
char
dirSeparator
;
char
pathSeparator
;
stringstream
sdirectory
(
directory
);
#ifdef WIN32
#ifdef WIN32
dirSeparator
=
'\\'
;
dirSeparator
=
'\\'
;
pathSeparator
=
';'
;
WIN32_FIND_DATA
fileInfo
;
WIN32_FIND_DATA
fileInfo
;
string
filePattern
(
directory
+
dirSeparator
+
"*.dll"
);
for
(
string
path
;
std
::
getline
(
sdirectory
,
path
,
pathSeparator
);)
{
string
filePattern
(
path
+
dirSeparator
+
"*.dll"
);
HANDLE
findHandle
=
FindFirstFile
(
filePattern
.
c_str
(),
&
fileInfo
);
HANDLE
findHandle
=
FindFirstFile
(
filePattern
.
c_str
(),
&
fileInfo
);
if
(
findHandle
!=
INVALID_HANDLE_VALUE
)
{
if
(
findHandle
!=
INVALID_HANDLE_VALUE
)
{
do
{
do
{
if
(
fileInfo
.
cFileName
[
0
]
!=
'.'
)
if
(
fileInfo
.
cFileName
[
0
]
!=
'.'
)
files
.
push_back
(
string
(
fileInfo
.
cFileName
));
files
.
push_back
(
path
+
dirSeparator
+
string
(
fileInfo
.
cFileName
));
}
while
(
FindNextFile
(
findHandle
,
&
fileInfo
));
}
while
(
FindNextFile
(
findHandle
,
&
fileInfo
));
FindClose
(
findHandle
);
FindClose
(
findHandle
);
}
}
}
vector
<
HMODULE
>
plugins
;
vector
<
HMODULE
>
plugins
;
#else
#else
dirSeparator
=
'/'
;
DIR
*
dir
;
DIR
*
dir
;
dirSeparator
=
'/'
;
pathSeparator
=
':'
;
struct
dirent
*
entry
;
struct
dirent
*
entry
;
dir
=
opendir
(
directory
.
c_str
());
for
(
string
path
;
std
::
getline
(
sdirectory
,
path
,
pathSeparator
);)
{
dir
=
opendir
(
path
.
c_str
());
if
(
dir
!=
NULL
)
{
if
(
dir
!=
NULL
)
{
while
((
entry
=
readdir
(
dir
))
!=
NULL
)
{
while
((
entry
=
readdir
(
dir
))
!=
NULL
)
{
if
(
entry
->
d_name
[
0
]
!=
'.'
)
if
(
entry
->
d_name
[
0
]
!=
'.'
)
files
.
push_back
(
string
(
entry
->
d_name
));
files
.
push_back
(
path
+
dirSeparator
+
string
(
entry
->
d_name
));
}
}
closedir
(
dir
);
closedir
(
dir
);
}
}
}
vector
<
void
*>
plugins
;
vector
<
void
*>
plugins
;
#endif
#endif
vector
<
string
>
loadedLibraries
;
vector
<
string
>
loadedLibraries
;
...
@@ -294,7 +305,7 @@ vector<string> Platform::loadPluginsFromDirectory(const string& directory) {
...
@@ -294,7 +305,7 @@ vector<string> Platform::loadPluginsFromDirectory(const string& directory) {
for
(
unsigned
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
for
(
unsigned
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
try
{
try
{
plugins
.
push_back
(
loadOneLibrary
(
directory
+
dirSeparator
+
files
[
i
]));
plugins
.
push_back
(
loadOneLibrary
(
files
[
i
]));
loadedLibraries
.
push_back
(
files
[
i
]);
loadedLibraries
.
push_back
(
files
[
i
]);
}
catch
(
OpenMMException
&
ex
)
{
}
catch
(
OpenMMException
&
ex
)
{
pluginLoadFailures
.
push_back
(
ex
.
what
());
pluginLoadFailures
.
push_back
(
ex
.
what
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment