diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2017-03-16 10:53:22 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@pelagicore.com> | 2017-03-22 10:37:26 +0000 |
commit | 8cabf3fb534d572c905fc0a783dbb4ebc98df41c (patch) | |
tree | e84abc9c260a970ebe1ac31638a9e7ff06336a59 | |
parent | 4ff4db090d09edf2964efbd092183c42d731a267 (diff) |
Don't expect "_simulaton" to be at the end of the plugin file name
On macOS debug plugins end with "_debug". Because of that our previous
detection of a simulation backend didn't work.
Also make sure we don't mix release builds with debug plugins and
vice versa.
Task-number: AUTOSUITE-47
Change-Id: I824528530dd3f0bd0a481f29f519eafc4de789bd
Reviewed-by: Vadim Popov <vadim.popov@pelagicore.com>
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
4 files changed, 44 insertions, 3 deletions
diff --git a/src/ivicore/qiviservicemanager.cpp b/src/ivicore/qiviservicemanager.cpp index 7403236..9bced91 100644 --- a/src/ivicore/qiviservicemanager.cpp +++ b/src/ivicore/qiviservicemanager.cpp @@ -61,6 +61,14 @@ Q_LOGGING_CATEGORY(qLcIviServiceManagement, "qt.ivi.servicemanagement"); QT_END_NAMESPACE +namespace qtivi_helper { +#ifdef QT_DEBUG + static const bool loadDebug = true; +#else + static const bool loadDebug = false; +#endif +} + QIviServiceManagerPrivate::QIviServiceManagerPrivate(QIviServiceManager *parent) : QObject(parent), q_ptr(parent) { } @@ -80,7 +88,7 @@ QList<QIviServiceObject *> QIviServiceManagerPrivate::findServiceByInterface(con if (backend->metaData[QLatin1String("interfaces")].toStringList().contains(interface)) { const QString& fileName = backend->metaData[QLatin1String("fileName")].toString(); - bool isSimulation = fileName.contains(QLatin1String("_simulation.")) || fileName.contains(QLatin1String("_simulator.")); + bool isSimulation = fileName.contains(QLatin1String("_simulation")) || fileName.contains(QLatin1String("_simulator")); if ((searchFlags & QIviServiceManager::IncludeSimulationBackends && isSimulation) || (searchFlags & QIviServiceManager::IncludeProductionBackends && !isSimulation)) { if (!backend->proxyServiceObject) { @@ -115,8 +123,10 @@ void QIviServiceManagerPrivate::searchPlugins() for (const QString &pluginPath : plugins) { if (!QLibrary::isLibrary(pluginPath)) continue; - QString fileName = QDir::cleanPath(path + QLatin1Char('/') + pluginPath); - QPluginLoader loader(dir.absoluteFilePath(fileName)); + const QString fileName = QDir::cleanPath(path + QLatin1Char('/') + pluginPath); + const QString absFileName = dir.absoluteFilePath(fileName); + QPluginLoader loader(absFileName); + registerBackend(loader.fileName(), loader.metaData()); found = true; } @@ -135,6 +145,13 @@ void QIviServiceManagerPrivate::registerBackend(const QString &fileName, const Q return; } + if (Q_UNLIKELY(metaData.value(QLatin1String("debug")).toBool() != qtivi_helper::loadDebug)) { + qCWarning(qLcIviServiceManagement, "Skipping incompatible plugin %s. " + "Expected build configuration '%s'", + qPrintable(fileName), qtivi_helper::loadDebug ? "debug" : "release"); + return; + } + //TODO check for other metaData like name etc. backendMetaData.insert(QLatin1String("fileName"), fileName); diff --git a/tests/auto/core/servicemanagertest/simple_plugin/simple_plugin.pro b/tests/auto/core/servicemanagertest/simple_plugin/simple_plugin.pro index f579710..4a90447 100644 --- a/tests/auto/core/servicemanagertest/simple_plugin/simple_plugin.pro +++ b/tests/auto/core/servicemanagertest/simple_plugin/simple_plugin.pro @@ -4,6 +4,14 @@ TEMPLATE = lib CONFIG += plugin QT += core ivicore +# On a macos framework build, we need both plugin versions, +# because debug/release is decided at runtime. +macos:qtConfig(framework) { + CONFIG += debug_and_release build_all + build_pass:CONFIG(debug, debug|release) { + TARGET = $$join(TARGET,,,_debug) + } +} SOURCES += simpleplugin.cpp \ diff --git a/tests/auto/core/servicemanagertest/wrong_plugin/wrong_plugin.pro b/tests/auto/core/servicemanagertest/wrong_plugin/wrong_plugin.pro index 52c216e..325f39d 100644 --- a/tests/auto/core/servicemanagertest/wrong_plugin/wrong_plugin.pro +++ b/tests/auto/core/servicemanagertest/wrong_plugin/wrong_plugin.pro @@ -4,6 +4,14 @@ TEMPLATE = lib CONFIG += plugin QT += core ivicore +# On a macos framework build, we need both plugin versions, +# because debug/release is decided at runtime. +macos:qtConfig(framework) { + CONFIG += debug_and_release build_all + build_pass:CONFIG(debug, debug|release) { + TARGET = $$join(TARGET,,,_debug) + } +} SOURCES += wrongplugin.cpp \ diff --git a/tests/auto/core/servicemanagertest/wrongmetadata_plugin/wrongmetadata_plugin.pro b/tests/auto/core/servicemanagertest/wrongmetadata_plugin/wrongmetadata_plugin.pro index 30a42cd..e57cf25 100644 --- a/tests/auto/core/servicemanagertest/wrongmetadata_plugin/wrongmetadata_plugin.pro +++ b/tests/auto/core/servicemanagertest/wrongmetadata_plugin/wrongmetadata_plugin.pro @@ -4,6 +4,14 @@ TEMPLATE = lib CONFIG += plugin QT += core ivicore +# On a macos framework build, we need both plugin versions, +# because debug/release is decided at runtime. +macos:qtConfig(framework) { + CONFIG += debug_and_release build_all + build_pass:CONFIG(debug, debug|release) { + TARGET = $$join(TARGET,,,_debug) + } +} SOURCES += wrongmetadataplugin.cpp \ |