diff options
author | Eike Ziller <eike.ziller@qt.io> | 2017-10-27 12:58:20 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2017-11-02 08:04:23 +0000 |
commit | bd0c6b0c44502ec7868718f48379c8e8d69c8230 (patch) | |
tree | 39fb59c9903cc079714fa290dfe95b4041f485ac /src | |
parent | 7b775f51f574a4875be414e636d82c325810dd02 (diff) | |
download | qttools-bd0c6b0c44502ec7868718f48379c8e8d69c8230.tar.gz |
Reduce some code duplication in macdeployqt
Change-Id: I52989b7b997999263df77361fdf75939c73f35f7
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/macdeployqt/shared/shared.cpp | 73 |
1 files changed, 28 insertions, 45 deletions
diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp index 957509019..83ad43f02 100644 --- a/src/macdeployqt/shared/shared.cpp +++ b/src/macdeployqt/shared/shared.cpp @@ -1029,6 +1029,16 @@ void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pl // Plugin white list: QStringList pluginList; + const auto addPlugins = [&pluginSourcePath,&pluginList](const QString &subDirectory, + const std::function<bool(QString)> &predicate = std::function<bool(QString)>()) { + const QStringList libs = QDir(pluginSourcePath + QLatin1Char('/') + subDirectory) + .entryList({QStringLiteral("*.dylib")}); + for (const QString &lib : libs) { + if (!lib.endsWith(QStringLiteral("_debug.dylib")) && (!predicate || predicate(lib))) + pluginList.append(subDirectory + QLatin1Char('/') + lib); + } + }; + // Platform plugin: pluginList.append("platforms/libqcocoa.dylib"); @@ -1039,64 +1049,37 @@ void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pl const QString libInfixWithFramework = getLibInfix(deploymentInfo.deployedFrameworks) + QStringLiteral(".framework"); // Network - if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtNetwork") + libInfixWithFramework)) { - QStringList bearerPlugins = QDir(pluginSourcePath + QStringLiteral("/bearer")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, bearerPlugins) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) - pluginList.append(QStringLiteral("bearer/") + plugin); - } - } + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtNetwork") + libInfixWithFramework)) + addPlugins(QStringLiteral("bearer")); // All image formats (svg if QtSvg.framework is used) - QStringList imagePlugins = QDir(pluginSourcePath + QStringLiteral("/imageformats")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, imagePlugins) { - if (plugin.contains(QStringLiteral("qsvg"))) { - if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSvg") + libInfixWithFramework)) - pluginList.append(QStringLiteral("imageformats/") + plugin); - } else if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) { - pluginList.append(QStringLiteral("imageformats/") + plugin); - } - } + const bool usesSvg = deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSvg") + libInfixWithFramework); + addPlugins(QStringLiteral("imageformats"), [usesSvg](const QString &lib) { + if (lib.contains(QStringLiteral("qsvg")) && !usesSvg) + return false; + return true; + }); - QStringList iconEngines = QDir(pluginSourcePath + QStringLiteral("/iconengines")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, iconEngines) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) { - pluginList.append(QStringLiteral("iconengines/") + plugin); - } - } + addPlugins(QStringLiteral("iconengines")); // Sql plugins if QtSql.framework is in use if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSql") + libInfixWithFramework)) { - QStringList sqlPlugins = QDir(pluginSourcePath + QStringLiteral("/sqldrivers")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, sqlPlugins) { - if (plugin.endsWith(QStringLiteral("_debug.dylib"))) - continue; - - // Some sql plugins are known to cause app store rejections. Skip or warn for these plugins. - if (plugin.startsWith(QStringLiteral("libqsqlodbc")) || plugin.startsWith(QStringLiteral("libqsqlpsql"))) { - LogWarning() << "Plugin" << plugin << "uses private API and is not Mac App store compliant."; + addPlugins(QStringLiteral("sqldrivers"), [](const QString &lib) { + if (lib.startsWith(QStringLiteral("libqsqlodbc")) || lib.startsWith(QStringLiteral("libqsqlpsql"))) { + LogWarning() << "Plugin" << lib << "uses private API and is not Mac App store compliant."; if (appstoreCompliant) { - LogWarning() << "Skip plugin" << plugin; - continue; + LogWarning() << "Skip plugin" << lib; + return false; } } - - pluginList.append(QStringLiteral("sqldrivers/") + plugin); - } + return true; + }); } // multimedia plugins if QtMultimedia.framework is in use if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtMultimedia") + libInfixWithFramework)) { - QStringList plugins = QDir(pluginSourcePath + QStringLiteral("/mediaservice")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, plugins) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) - pluginList.append(QStringLiteral("mediaservice/") + plugin); - } - plugins = QDir(pluginSourcePath + QStringLiteral("/audio")).entryList(QStringList() << QStringLiteral("*.dylib")); - foreach (const QString &plugin, plugins) { - if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) - pluginList.append(QStringLiteral("audio/") + plugin); - } + addPlugins(QStringLiteral("mediaservice")); + addPlugins(QStringLiteral("audio")); } foreach (const QString &plugin, pluginList) { |