Commit 3facb9ff authored by saubatn's avatar saubatn

UPDATED : Add Core::isDebugBuild() method.

UPDATED : ExtensionManager now only loads libraries that corresponds to its build type (debug, release).

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@731 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 367a75f3
......@@ -33,11 +33,22 @@
// -- QT stuff
#include <QDir>
#include <QApplication>
#include <QLibraryInfo>
namespace camitk {
QString Core::binDirName;
// ------------- isDebugBuild (static) -----------------
const bool Core::isDebugBuild()
{
#ifdef QT_DEBUG
return true;
#else
return false;
#endif
}
// ------------- getConfig (static) -----------------
const QString Core::getConfig() {
QStringList diagnosis;
......@@ -302,7 +313,12 @@ const QString Core::getRootDir() {
// ------------- checkCoreLibDir (static) -----------------
bool Core::checkCoreLibDir(QString dir) {
QStringList coreLibFilter;
coreLibFilter << "*camitkcore.so." + QString(Core::soVersion) << "*camitkcore.dll" << "*camitkcored.dll" << "*camitkcore.dylib";
coreLibFilter << "*camitkcore.so." + QString(Core::soVersion) << "*camitkcore.dylib";
if (isDebugBuild())
coreLibFilter << "*camitkcored.dll";
else
coreLibFilter << "*camitkcore.dll";
QStringList coreLibs = QDir(dir).entryList(coreLibFilter, QDir::Files);
return (coreLibs.size()==1);
}
......
......@@ -115,6 +115,14 @@ namespace camitk {
class CAMITK_API Core {
public:
/// @name runtime build information
///@{
/// get the type of build we are running, Debug or Release
/// @return true if running in Debug, elsewhere false for Release build.
static const bool isDebugBuild();
///@}
/// @name runtime directory information
///@{
/// get the camitk component extension directory name
......
......@@ -80,11 +80,33 @@ void ExtensionManager::autoloadComponentExtensions() {
// try to load all Components in the directory
QStringList pluginFile;
// linux: .so, windows: .dll, macOs: .dylib
pluginFile << "*.so." + QString(Core::soVersion) << "*.dll" << "*.dylib";
pluginFile << "*.so." + QString(Core::soVersion) << "*.dylib";
if (Core::isDebugBuild())
pluginFile << "*d.dll";
else
pluginFile << "*.dll";
// loop to load component plugin, taking into account internal dependencies (i.e. dependency between
// one component and another one.
QStringList pluginFileNames = extensionsDir.entryList(pluginFile, QDir::Files);
QStringList pluginFileNamesDebug = extensionsDir.entryList(QStringList("*d.dll"), QDir::Files);
if (Core::isDebugBuild())
{
// remove specific component libs ending names with an "d" which are not compiled in debug
if (pluginFileNames.contains("mixed.dll"))
pluginFileNames.removeAll("mixed.dll");
}
else
{
// remove debug action libraries from list to load
if (pluginFileNamesDebug.contains("mixed.dll"))
pluginFileNamesDebug.removeAll("mixed.dll");
QStringListIterator i(pluginFileNamesDebug);
while(i.hasNext())
pluginFileNames.removeAll(i.next());
}
// if there is more than 5 dependency levels, then you have two choices:
// - consider simplifying your component
// - increase maxNumberOfTries
......@@ -298,12 +320,33 @@ void ExtensionManager::autoloadActionExtensions() {
else {
// try to load all Components in the directory
QStringList extensionFile;
extensionFile << "*.so." + QString(Core::soVersion) << "*.dll" << "*.dylib";
extensionFile << "*.so." + QString(Core::soVersion) << "*.dylib";
if (Core::isDebugBuild())
extensionFile << "*d.dll";
else
extensionFile << "*.dll";
// loop to load action extension, taking into account internal dependencies (i.e. dependency between
// one action and another one.
int i = 0;
QStringList extensionFileNames = actionsDir.entryList(extensionFile, QDir::Files);
QStringList extensionFileNamesDebug = actionsDir.entryList(QStringList("*d.dll"), QDir::Files);
if (Core::isDebugBuild())
{
// remove specific action libs ending names with an "d" which are not compiled in debug
if (extensionFileNames.contains("showin3d.dll"))
extensionFileNames.removeAll("showin3d.dll");
}
else
{
// remove debug action libraries from list to load
if (extensionFileNamesDebug.contains("showin3d.dll"))
extensionFileNamesDebug.removeAll("showin3d.dll");
QStringListIterator i(extensionFileNamesDebug);
while(i.hasNext())
extensionFileNames.removeAll(i.next());
}
// if there is more than 5 dependency levels, then you have two choices:
// - consider simplifying your component
// - increase maxNumberOfTries
......
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