From b8739f2fb33a28a250cd2053c013b977a3f096e8 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 13 Feb 2018 07:51:52 -0500 Subject: Enable specifying directories in plugin-files. --- src/libstore/globals.cc | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/libstore/globals.cc') diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 21ab0e6296ef..c6b508cbe82f 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -142,12 +142,24 @@ void MaxBuildJobsSetting::set(const std::string & str) void initPlugins() { for (const auto & pluginFile : settings.pluginFiles.get()) { - /* handle is purposefully leaked as there may be state in the - DSO needed by the action of the plugin. */ - void *handle = - dlopen(pluginFile.c_str(), RTLD_LAZY | RTLD_LOCAL); - if (!handle) - throw Error(format("could not dynamically open plugin file '%1%': %2%") % pluginFile % dlerror()); + Paths pluginFiles; + try { + auto ents = readDirectory(pluginFile); + for (const auto & ent : ents) + pluginFiles.emplace_back(pluginFile + "/" + ent.name); + } 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()); + } } } -- cgit 1.4.1