Commit 5888da12 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] - module path now gets calculated in kernel

parent 65808f7c
......@@ -67,6 +67,11 @@ boost::filesystem::path WKernel::m_appPath = boost::filesystem::path();
*/
boost::filesystem::path WKernel::m_fontPath = boost::filesystem::path();
/**
* The path for modules.
*/
boost::filesystem::path WKernel::m_modulePath = boost::filesystem::path();
WKernel::WKernel( boost::shared_ptr< WGraphicsEngine > ge, boost::shared_ptr< WGUI > gui ):
WThreadedRunner()
{
......@@ -207,8 +212,18 @@ void WKernel::findAppPath()
m_shaderPath = fs::path( currentDir / "shaders" );
WLogger::getLogger()->addLogMessage( "Shader path: " + m_shaderPath.file_string(), "Kernel", LL_DEBUG );
// NOTE: currently, OpenSceneGraph has hard-coded its search path for fonts. So we can't change it to somewhere else currently.
m_fontPath = fs::path( currentDir / "fonts" );
WLogger::getLogger()->addLogMessage( "Font path: " + m_fontPath.file_string(), "Kernel", LL_DEBUG );
// the module path. use WSharedLib to find it basing on the bin- dir
std::string libPath = "";
if ( !WPreferences::getPreference( "modules.path", &libPath ) )
{
m_modulePath = fs::path( currentDir / WSharedLib::getSystemLibPath() );
}
WLogger::getLogger()->addLogMessage( "Module path: " + m_modulePath.file_string(), "Kernel", LL_DEBUG );
}
const WBoolFlag& WKernel::isFinishRequested() const
......@@ -249,6 +264,12 @@ std::string WKernel::getShaderPath()
return WKernel::m_shaderPath.file_string();
}
std::string WKernel::getModulePath()
{
findAppPath();
return WKernel::m_modulePath.file_string();
}
boost::shared_ptr< WROIManagerFibers> WKernel::getRoiManager()
{
return m_roiManager;
......
......@@ -163,6 +163,13 @@ public:
*/
static std::string getShaderPath();
/**
* Getter for the module path. This is the directory where to search for modules.
*
* \return the module search path
*/
static std::string getModulePath();
/**
* get for roi manager
*/
......@@ -242,10 +249,15 @@ private:
*/
static boost::filesystem::path m_shaderPath;
/**
/**
* The location of the font files.
*/
static boost::filesystem::path m_fontPath;
/**
* The location of the modules.
*/
static boost::filesystem::path m_modulePath;
};
#endif // WKERNEL_H
......
......@@ -29,15 +29,13 @@
#include "../common/WPreferences.h"
#include "../common/WSharedLib.h"
#include "WKernel.h"
#include "WModuleLoader.h"
WModuleLoader::WModuleLoader( ):
m_path( "." )
WModuleLoader::WModuleLoader( )
{
// initialize members
std::string libPath = WSharedLib::getSystemLibPath();
WPreferences::getPreference( "modules.path", &libPath );
m_path = boost::filesystem::path( libPath );
}
WModuleLoader::~WModuleLoader()
......@@ -48,13 +46,12 @@ WModuleLoader::~WModuleLoader()
void WModuleLoader::load( WSharedAssociativeContainer< std::set< boost::shared_ptr< WModule > > >::WriteTicket ticket )
{
// iterate module directory, look for .so,.dll,.dylib files
WAssert( boost::filesystem::exists( m_path ), "" );
std::string modulePath = WKernel::getModulePath();
WLogger::getLogger()->addLogMessage( "Searching modules in \"" + m_path.file_string() + "\" with prefix \"" + getModulePrefix() + "\".",
WLogger::getLogger()->addLogMessage( "Searching modules in \"" + modulePath + "\" with prefix \"" + getModulePrefix() + "\".",
"Module Loader", LL_INFO );
for( boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator( m_path );
for( boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator( modulePath );
i != boost::filesystem::directory_iterator(); ++i )
{
// all modules need to begin with this
......
......@@ -75,10 +75,6 @@ private:
*/
std::vector< WSharedLib > m_libs;
/**
* Path to the modules. This is used during load to find all libMODULENAME.{so,dll,dylib} files.
*/
boost::filesystem::path m_path;
};
#endif // WMODULELOADER_H
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