##// 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 35 namespace {
36 36
37 /// Name of the directory containing the plugins
38
39 #if _WIN32 || _WIN64
40 37 const auto PLUGIN_DIRECTORY_NAME = QStringLiteral("plugins");
41 #endif
38
42 39
43 40 } // namespace
44 41
@@ -52,28 +49,32 int main(int argc, char *argv[])
52 49 w.show();
53 50
54 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 63 #if _WIN32 || _WIN64
57 64 pluginDir.mkdir(PLUGIN_DIRECTORY_NAME);
58 65 pluginDir.cd(PLUGIN_DIRECTORY_NAME);
59 66 #endif
60 67
68 PluginManager pluginManager{};
61 69
62 #if __unix || __APPLE
63 #if __x86_64__ || __ppc64__
64 if (!pluginDir.cd("../lib64/SciQlop")) {
65 pluginDir.cd("../lib64/sciqlop");
70 for (auto &&path : pluginLookupPath) {
71 QDir directory{path};
72 if (directory.exists()) {
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 79 return a.exec();
79 80 }
@@ -106,9 +106,15 PluginManager::PluginManager() : impl{spimpl::make_unique_impl<PluginManagerPriv
106 106 void PluginManager::loadPlugins(const QDir &pluginDir)
107 107 {
108 108 // Load plugins
109 auto pluginInfoList = pluginDir.entryInfoList(QDir::Files, QDir::Name);
110 for (auto pluginInfo : qAsConst(pluginInfoList)) {
111 impl->loadPlugin(pluginInfo.absoluteFilePath());
109 auto pluginInfoList
110 = pluginDir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
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 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 43 amdaplugin_moc_files = qt5.preprocess(
41 44 ui_files : amdaplugin_ui_files)
42 45
@@ -45,7 +48,7 sciqlop_amdaplugin = library('amdaplugin',
45 48 amdaplugin_moc_files,
46 49 amdaplugin_rcc_plugin_files,
47 50 amdaplugin_moc_plugin_files,
48 cpp_args : '-DAMDA_LIB',
51 cpp_args : ['-DAMDA_LIB','-DQT_PLUGIN'],
49 52 link_with : [sciqlop_core, sciqlop_gui],
50 53 include_directories : [amdaplugin_inc, core_inc, gui_inc],
51 54 dependencies : [qt5core, qt5gui, qt5widgets, qt5network],
General Comments 0
You need to be logged in to leave comments. Login now