forked from lix-project/lix
Enable specifying directories in plugin-files.
This commit is contained in:
parent
f471aacff2
commit
b8739f2fb3
|
@ -764,6 +764,10 @@ builtins.fetchurl {
|
||||||
should not be linked to any Nix libs directly, as those will
|
should not be linked to any Nix libs directly, as those will
|
||||||
be available already at load time.
|
be available already at load time.
|
||||||
</para>
|
</para>
|
||||||
|
<para>
|
||||||
|
If an entry in the list is a directory, all files in the
|
||||||
|
directory are loaded as plugins (non-recursively).
|
||||||
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
|
@ -142,12 +142,24 @@ void MaxBuildJobsSetting::set(const std::string & str)
|
||||||
void initPlugins()
|
void initPlugins()
|
||||||
{
|
{
|
||||||
for (const auto & pluginFile : settings.pluginFiles.get()) {
|
for (const auto & pluginFile : settings.pluginFiles.get()) {
|
||||||
/* handle is purposefully leaked as there may be state in the
|
Paths pluginFiles;
|
||||||
DSO needed by the action of the plugin. */
|
try {
|
||||||
void *handle =
|
auto ents = readDirectory(pluginFile);
|
||||||
dlopen(pluginFile.c_str(), RTLD_LAZY | RTLD_LOCAL);
|
for (const auto & ent : ents)
|
||||||
if (!handle)
|
pluginFiles.emplace_back(pluginFile + "/" + ent.name);
|
||||||
throw Error(format("could not dynamically open plugin file '%1%': %2%") % pluginFile % dlerror());
|
} catch (SysError & e) {
|
||||||
|
if (e.errNo != ENOTDIR)
|
||||||
|
throw;
|
||||||
|
pluginFiles.emplace_back(pluginFile);
|
||||||
|
}
|
||||||
|
for (const auto & file : pluginFiles) {
|
||||||
|
/* handle is purposefully leaked as there may be state in the
|
||||||
|
DSO needed by the action of the plugin. */
|
||||||
|
void *handle =
|
||||||
|
dlopen(file.c_str(), RTLD_LAZY | RTLD_LOCAL);
|
||||||
|
if (!handle)
|
||||||
|
throw Error("could not dynamically open plugin file '%s%': %s%", file, dlerror());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue