From 3f80c821e939cd908651d20940fb41b2522dc199 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 6 May 2019 11:08:25 +0200 Subject: Qt: Do not link static plugins into static libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plugins should only be linked into applications and shared libraries. Change-Id: I95adc3f1f1ec8ea512e4166e78be1d9c5abb6745 Fixes: QBS-1441 Reviewed-by: Ola Røer Thorsen Reviewed-by: Joerg Bornemann --- doc/reference/modules/qt-plugin_support-module.qdoc | 8 ++++++++ share/qbs/module-providers/Qt/templates/QtPlugin.qbs | 2 ++ share/qbs/module-providers/Qt/templates/plugin_support.qbs | 2 ++ share/qbs/module-providers/Qt/templates/qml.qbs | 7 ++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/doc/reference/modules/qt-plugin_support-module.qdoc b/doc/reference/modules/qt-plugin_support-module.qdoc index fe28ee907..9bd27c3f7 100644 --- a/doc/reference/modules/qt-plugin_support-module.qdoc +++ b/doc/reference/modules/qt-plugin_support-module.qdoc @@ -75,3 +75,11 @@ \readonly */ +/*! + \qmlproperty bool Qt.plugin_support::linkPlugins + + Controls whether plugins of a statically built Qt should be linked into the product. + + \default \true if the product is an application or shared library, \c false otherwise. + +*/ diff --git a/share/qbs/module-providers/Qt/templates/QtPlugin.qbs b/share/qbs/module-providers/Qt/templates/QtPlugin.qbs index 23a6795f3..88bfa5a65 100644 --- a/share/qbs/module-providers/Qt/templates/QtPlugin.qbs +++ b/share/qbs/module-providers/Qt/templates/QtPlugin.qbs @@ -12,6 +12,8 @@ QtModule { return false; if (!isStaticLibrary) return false; + if (!Qt.plugin_support.linkPlugins) + return false; if (!(Qt.plugin_support.enabledPlugins || []).contains(qtModuleName)) return false; if (!extendsModules || extendsModules.length === 0) diff --git a/share/qbs/module-providers/Qt/templates/plugin_support.qbs b/share/qbs/module-providers/Qt/templates/plugin_support.qbs index 13d95c383..1de923f17 100644 --- a/share/qbs/module-providers/Qt/templates/plugin_support.qbs +++ b/share/qbs/module-providers/Qt/templates/plugin_support.qbs @@ -1,6 +1,8 @@ Module { // Set by user. property varList pluginsByType + property bool linkPlugins: product.type + && (product.type.contains("application") || product.type.contains("sharedlibrary")) // Set by Qt modules. property stringList pluginTypes diff --git a/share/qbs/module-providers/Qt/templates/qml.qbs b/share/qbs/module-providers/Qt/templates/qml.qbs index 2b11abbd5..c95c0f367 100644 --- a/share/qbs/module-providers/Qt/templates/qml.qbs +++ b/share/qbs/module-providers/Qt/templates/qml.qbs @@ -24,12 +24,13 @@ QtModule { readonly property string pluginListFilePathDebug: product.buildDirectory + "/plugins.list.d" readonly property string pluginListFilePathRelease: product.buildDirectory + "/plugins.list" + property bool linkPlugins: isStaticLibrary && Qt.plugin_support.linkPlugins hasLibrary: @has_library@ architectures: @archs@ targetPlatform: @targetPlatform@ - staticLibsDebug: (isStaticLibrary ? ['@' + pluginListFilePathDebug] : []).concat(@staticLibsDebug@) - staticLibsRelease: (isStaticLibrary ? ['@' + pluginListFilePathRelease] : []).concat(@staticLibsRelease@) + staticLibsDebug: (linkPlugins ? ['@' + pluginListFilePathDebug] : []).concat(@staticLibsDebug@) + staticLibsRelease: (linkPlugins ? ['@' + pluginListFilePathRelease] : []).concat(@staticLibsRelease@) dynamicLibsDebug: @dynamicLibsDebug@ dynamicLibsRelease: @dynamicLibsRelease@ linkerFlagsDebug: @linkerFlagsDebug@ @@ -60,7 +61,7 @@ QtModule { } Rule { - condition: isStaticLibrary + condition: linkPlugins multiplex: true requiresInputs: false inputs: ["qt.qml.qml"] -- cgit v1.2.3