diff options
author | Morten Johan Sorvig <morten.sorvig@digia.com> | 2012-10-24 13:04:27 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-15 07:28:47 +0100 |
commit | 83f67b09c1b2b994d1252c4494d51072d2c51435 (patch) | |
tree | 71b6d951335bbd6371a18e5b7fdb0c905ee612ab /src | |
parent | fbe2498c2df516fa4dd4c1cf209797ebeecc2fb2 (diff) |
Make plugin deployment white-list based.
Deploy specific plugins instead of deploying all
plugins with exceptions.
Before macdeployqt would deploy nearly all plugins.
The plugins themselves weren't necessarily a problem,
but this would also pull in all plugin dependencies,
massively bloating the app bundle.
Change-Id: Ia8d8b795101958da83b299e1d8922a01b5e8f13d
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/macdeployqt/shared/shared.cpp | 100 |
1 files changed, 45 insertions, 55 deletions
diff --git a/src/macdeployqt/shared/shared.cpp b/src/macdeployqt/shared/shared.cpp index 55c08c967..1bb0ef60c 100644 --- a/src/macdeployqt/shared/shared.cpp +++ b/src/macdeployqt/shared/shared.cpp @@ -489,75 +489,65 @@ void deployPlugins(const ApplicationBundleInfo &appBundleInfo, const QString &pl const QString pluginDestinationPath, DeploymentInfo deploymentInfo, bool useDebugLibs) { LogNormal() << "Deploying plugins from" << pluginSourcePath; - QStringList plugins = QDir(pluginSourcePath).entryList(QStringList() << "*.dylib"); - foreach (QString pluginName, plugins) { - if (pluginSourcePath.contains(deploymentInfo.pluginPath)) { - QStringList deployedFrameworks = deploymentInfo.deployedFrameworks; - - // Skip the debug versions of the plugins, unless specified otherwise. - if (!useDebugLibs && pluginName.endsWith("_debug.dylib")) - continue; - - // Skip the release versions of the plugins, unless specified otherwise. - if (useDebugLibs && !pluginName.endsWith("_debug.dylib")) - continue; - - // Skip the designer plugins - if (pluginSourcePath.contains("plugins/designer")) - continue; - -#ifndef QT_GRAPHICSSYSTEM_OPENGL - // SKip the opengl graphicssystem plugin when not in use. - if (pluginName.contains("libqglgraphicssystem")) - continue; -#endif - // Deploy accessibility for Qt3Support only if the Qt3Support.framework is in use - if (deployedFrameworks.indexOf("Qt3Support.framework") == -1 && pluginName.contains("accessiblecompatwidgets")) - continue; + if (!pluginSourcePath.contains(deploymentInfo.pluginPath)) + return; - // Deploy the svg icon plugin if QtSvg.framework is in use. - if (deployedFrameworks.indexOf("QtSvg.framework") == -1 && pluginName.contains("svg")) - continue; + // Plugin white list: + QStringList pluginList; + + // Platform plugin: + pluginList.append("platforms/libqcocoa.dylib"); + + // Cocoa print support + pluginList.append("printsupport/libcocoaprintersupport.dylib"); + + // Accessibility + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtWidgets.framework"))) + pluginList.append("accessible/libqtaccessiblewidgets.dylib"); + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtQuick.framework"))) + pluginList.append("accessible/libqtaccessiblequick.dylib"); + + // 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.framework"))) + pluginList.append(QStringLiteral("imageformats/") + plugin); + } else if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) { + pluginList.append(QStringLiteral("imageformats/") + plugin); + } + } - // Deploy the phonon plugins if phonon.framework is in use - if (deployedFrameworks.indexOf("phonon.framework") == -1 && pluginName.contains("phonon")) - continue; + // Sql plugins if QtSql.framework is in use + if (deploymentInfo.deployedFrameworks.contains(QStringLiteral("QtSql.framework"))) { + QStringList sqlPlugins = QDir(pluginSourcePath + QStringLiteral("/sqldrivers")).entryList(QStringList() << QStringLiteral("*.dylib")); + foreach (const QString &plugin, sqlPlugins) { + if (!plugin.endsWith(QStringLiteral("_debug.dylib"))) + pluginList.append(QStringLiteral("/sqldrivers") + plugin); + } + } - // Deploy the sql plugins if QtSql.framework is in use - if (deployedFrameworks.indexOf("QtSql.framework") == -1 && pluginName.contains("sql")) - continue; + foreach (const QString &plugin, pluginList) { - // Deploy the script plugins if QtScript.framework is in use - if (deployedFrameworks.indexOf("QtScript.framework") == -1 && pluginName.contains("script")) - continue; + QString sourcePath = pluginSourcePath + "/" + plugin; + if (useDebugLibs) { + // Use debug plugins if found. + QString debugSourcePath = sourcePath.replace(".dylib", "_debug.dylib"); + if (QFile::exists(debugSourcePath)) + sourcePath = debugSourcePath; } + const QString destinationPath = pluginDestinationPath + "/" + plugin; QDir dir; - dir.mkpath(pluginDestinationPath); + dir.mkpath(QFileInfo(destinationPath).path()); - const QString sourcePath = pluginSourcePath + "/" + pluginName; - const QString destinationPath = pluginDestinationPath + "/" + pluginName; if (copyFilePrintStatus(sourcePath, destinationPath)) { - runStrip(destinationPath); - - // Special case for the phonon plugin: CoreVideo is not available as a separate framework - // on panther, link against the QuartzCore framework instead. (QuartzCore contians CoreVideo.) - if (pluginName.contains("libphonon_qt7")) { - changeInstallName("/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo", - "/System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore", - destinationPath); - } - QList<FrameworkInfo> frameworks = getQtFrameworks(destinationPath, useDebugLibs); deployQtFrameworks(frameworks, appBundleInfo.path, QStringList() << destinationPath, useDebugLibs, deploymentInfo.useLoaderPath); } - } // foreach plugins - - QStringList subdirs = QDir(pluginSourcePath).entryList(QStringList() << "*", QDir::Dirs | QDir::NoDotAndDotDot); - foreach (const QString &subdir, subdirs) - deployPlugins(appBundleInfo, pluginSourcePath + "/" + subdir, pluginDestinationPath + "/" + subdir, deploymentInfo, useDebugLibs); + } } void createQtConf(const QString &appBundlePath) |