Fix module path

parent 99cab7bc
......@@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include_directories("${CMAKE_SOURCE_DIR}/modules")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/melanobot")
link_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB SUBDIRS RELATIVE "${CMAKE_SOURCE_DIR}/modules" ${CMAKE_SOURCE_DIR}/modules/*)
......
......@@ -34,10 +34,11 @@ void gather_metadata(const std::string& search_path,
static std::regex regex(R"re(lib(melanomodule_[-_.a-zA-Z0-9]+).so)re",
std::regex::optimize|std::regex::extended);
boost::filesystem::path path(search_path);
if ( !boost::filesystem::exists(search_path) )
return;
using diriter = boost::filesystem::directory_iterator;
boost::iterator_range<diriter> range{diriter(path), diriter{}};
boost::iterator_range<diriter> range{diriter(search_path), diriter{}};
for ( const auto& entry : range )
{
......
......@@ -36,8 +36,10 @@ int main(int argc, char **argv)
auto lib_path = settings::global_settings.get("path.library", "");
auto modules =
module::initialize_modules<const Settings&>({lib_path}, settings);
auto modules = module::initialize_modules<const Settings&>(
string::char_split(lib_path, ':'),
settings
);
// Load log settings again to ensure log types defined by modules
// are handled correctly
......
......@@ -59,9 +59,18 @@ Settings settings::initialize ( int argc, char** argv )
if ( !err )
{
global_settings.put("path.executable", exe_dir.string());
global_settings.put("path.library", (exe_dir.parent_path()/"lib").string());
}
// Library paths
std::vector<std::string> library_path;
boost::filesystem::path dir("/lib/melanobot");
library_path.push_back("/usr"+dir.string());
library_path.push_back("/usr/local"+dir.string());
if ( !err )
{
library_path.push_back((exe_dir.parent_path()/dir).string());
}
global_settings.put("path.library", string::implode(":", library_path));
// Home
path = std::getenv("HOME");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment