##// END OF EJS Templates
Some minor improvements on plugin loading:...
jeandet -
r609:7c40e9303976
parent child
Show More
@@ -34,11 +34,8 Q_LOGGING_CATEGORY(LOG_Main, "Main")
34
34
35 namespace {
35 namespace {
36
36
37 /// Name of the directory containing the plugins
38
39 #if _WIN32 || _WIN64
40 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins");
37 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins");
41 #endif
38
42
39
43 } // namespace
40 } // namespace
44
41
@@ -52,28 +49,32 int main(int argc, char *argv[])
52 w.show();
49 w.show();
53
50
54 // Loads plugins
51 // Loads plugins
55 auto pluginDir = QDir{sqpApp->applicationDirPath()};
52 auto pluginDir = QDir{a.applicationDirPath()};
53 auto pluginLookupPath = {
54 a.applicationDirPath(),
55 a.applicationDirPath() + "/" + PLUGIN_DIRECTORY_NAME,
56 a.applicationDirPath() + "/../lib64/SciQlop",
57 a.applicationDirPath() + "/../lib64/sciqlop",
58 a.applicationDirPath() + "/../lib/SciQlop",
59 a.applicationDirPath() + "/../lib/sciqlop",
60 a.applicationDirPath() + "/../plugins",
61 };
62
56 #if _WIN32 || _WIN64
63 #if _WIN32 || _WIN64
57 pluginDir.mkdir(PLUGIN_DIRECTORY_NAME);
64 pluginDir.mkdir(PLUGIN_DIRECTORY_NAME);
58 pluginDir.cd(PLUGIN_DIRECTORY_NAME);
65 pluginDir.cd(PLUGIN_DIRECTORY_NAME);
59 #endif
66 #endif
60
67
68 PluginManager pluginManager{};
61
69
62 #if __unix || __APPLE
70 for (auto &&path : pluginLookupPath) {
63 #if __x86_64__ || __ppc64__
71 QDir directory{path};
64 if (!pluginDir.cd("../lib64/SciQlop")) {
72 if (directory.exists()) {
65 pluginDir.cd("../lib64/sciqlop");
73 qCDebug(LOG_Main())
74 << QObject::tr("Plugin directory: %1").arg(directory.absolutePath());
75 pluginManager.loadPlugins(directory);
76 }
66 }
77 }
67 #else
68 if (!pluginDir.cd("../lib/SciQlop")) {
69 pluginDir.cd("../lib/sciqlop");
70 }
71 #endif
72 #endif
73 qCDebug(LOG_Main()) << QObject::tr("Plugin directory: %1").arg(pluginDir.absolutePath());
74
75 PluginManager pluginManager{};
76 pluginManager.loadPlugins(pluginDir);
77
78
78 return a.exec();
79 return a.exec();
79 }
80 }
@@ -106,9 +106,15 PluginManager::PluginManager() : impl{spimpl::make_unique_impl<PluginManagerPriv
106 void PluginManager::loadPlugins(const QDir &pluginDir)
106 void PluginManager::loadPlugins(const QDir &pluginDir)
107 {
107 {
108 // Load plugins
108 // Load plugins
109 auto pluginInfoList = pluginDir.entryInfoList(QDir::Files, QDir::Name);
109 auto pluginInfoList
110 for (auto pluginInfo : qAsConst(pluginInfoList)) {
110 = pluginDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
111 impl->loadPlugin(pluginInfo.absoluteFilePath());
111 for (auto entryInfo : qAsConst(pluginInfoList)) {
112 if (entryInfo.isDir())
113 this->loadPlugins(QDir{entryInfo.absoluteFilePath()});
114 else {
115 if (QLibrary::isLibrary(entryInfo.absoluteFilePath()))
116 impl->loadPlugin(entryInfo.absoluteFilePath());
117 }
112 }
118 }
113 }
119 }
114
120
@@ -37,6 +37,9 amdaplugin_moc_plugin_files = moc_gen.process(amdaplugin_moc_headers)
37
37
38 amdaplugin_rcc_plugin_files = rcc_gen.process(amdaplugin_resources_files)
38 amdaplugin_rcc_plugin_files = rcc_gen.process(amdaplugin_resources_files)
39
39
40 #amdaplugin_rcc_plugin_files = qt5.preprocess(
41 # qresources : amdaplugin_resources_files)
42
40 amdaplugin_moc_files = qt5.preprocess(
43 amdaplugin_moc_files = qt5.preprocess(
41 ui_files : amdaplugin_ui_files)
44 ui_files : amdaplugin_ui_files)
42
45
@@ -45,7 +48,7 sciqlop_amdaplugin = library('amdaplugin',
45 amdaplugin_moc_files,
48 amdaplugin_moc_files,
46 amdaplugin_rcc_plugin_files,
49 amdaplugin_rcc_plugin_files,
47 amdaplugin_moc_plugin_files,
50 amdaplugin_moc_plugin_files,
48 cpp_args : '-DAMDA_LIB',
51 cpp_args : ['-DAMDA_LIB','-DQT_PLUGIN'],
49 link_with : [sciqlop_core, sciqlop_gui],
52 link_with : [sciqlop_core, sciqlop_gui],
50 include_directories : [amdaplugin_inc, core_inc, gui_inc],
53 include_directories : [amdaplugin_inc, core_inc, gui_inc],
51 dependencies : [qt5core, qt5gui, qt5widgets, qt5network],
54 dependencies : [qt5core, qt5gui, qt5widgets, qt5network],
General Comments 0
You need to be logged in to leave comments. Login now