From 623b191c10ad36a82e31b8af794b6e04ae18775f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 20:20:35 +0100 Subject: track plugins' qt dependencies plugins may pull in additional qt modules which may require additional plugins in turn. Change-Id: I22264b39c1397666b2dc9079048ed1fc64aa84d9 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 148 +++++++++++++++++++++++++++--------------------- 1 file changed, 84 insertions(+), 64 deletions(-) (limited to 'mkspecs/features/qt.prf') diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 564f3d774d..626cf9c809 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -45,9 +45,93 @@ qaxserver { QT += axserver } +!import_qpa_plugin { + warning("CONFIG-=import_qpa_plugin is deprecated. Use QTPLUGIN.platforms=- instead.") + QTPLUGIN.platforms = - +} else: qpa_minimal_plugin { + warning("CONFIG+=qpa_minimal_plugin is deprecated. Use QTPLUGIN.platforms=qminimal instead.") + QTPLUGIN.platforms = qminimal +} + !force_import_plugins:!contains(TEMPLATE, ".*app"):!if(contains(TEMPLATE, ".*lib"):dll): \ CONFIG -= import_plugins +# qmake variables cannot contain dashes, so normalize the names first +CLEAN_QT = $$replace(QT, -private$, _private) +CLEAN_QT_PRIVATE = $$replace(QT_PRIVATE, -private$, _private) + +qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE +all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") + +import_plugins:qtConfig(static) { + manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy. + autoplugs = # Auto-added plugins. + # First round: explicitly specified modules. + plugin_deps = $$all_qt_module_deps + for(ever) { + # Automatically link the default plugins for the linked Qt modules. + for (qtmod, plugin_deps) { + for (ptype, QT.$${qtmod}.plugin_types) { + nptype = $$replace(ptype, [-/], _) + isEmpty(QTPLUGIN.$$nptype) { + for (plug, QT_PLUGINS) { + equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { + for (dep, QT_PLUGIN.$${plug}.EXTENDS) { + !contains(all_qt_module_deps, $$dep) { + plug = + break() + } + } + autoplugs += $$plug + } + } + } else { + plug = $$eval(QTPLUGIN.$$nptype) + !equals(plug, -): \ + autoplugs += $$plug + } + } + } + QTPLUGIN = $$manualplugs $$autoplugs + QTPLUGIN = $$unique(QTPLUGIN) + + # Obtain the plugins' Qt dependencies ... + plugin_deps = + for (plug, QTPLUGIN): \ + plugin_deps += $$eval(QT_PLUGIN.$${plug}.DEPENDS) + plugin_deps = $$resolve_depends(plugin_deps, "QT.", ".depends" ".run_depends") + plugin_deps -= $$all_qt_module_deps + isEmpty(plugin_deps): \ + break() + # ... and start over if any new Qt modules appeared, + # as these may want to load plugins in turn. + all_qt_module_deps += $$plugin_deps + } + extraplugs = $$manualplugs + manualplugs -= $$autoplugs + extraplugs -= $$manualplugs + !isEmpty(extraplugs): \ + warning("Redundant entries in QTPLUGIN: $$extraplugs") + + !isEmpty(QTPLUGIN) { + IMPORT_FILE_CONT = \ + "// This file is autogenerated by qmake. It imports static plugin classes for" \ + "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS. variables." \ + "$${LITERAL_HASH}include " + for (plug, QTPLUGIN) { + plug_class = $$eval(QT_PLUGIN.$${plug}.CLASS_NAME) + !isEmpty(plug_class): \ + IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$plug_class)" + else: \ + warning("Plugin class name could not be determined for plugin '$$plug'.") + } + IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_import.cpp + write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() + GENERATED_SOURCES += $$IMPORT_CPP + QMAKE_DISTCLEAN += $$IMPORT_CPP + } +} + # target variable, flag source variable defineTest(qtProcessModuleFlags) { for(flag, $$2) { @@ -62,8 +146,6 @@ defineTest(qtProcessModuleFlags) { unset(using_privates) var_sfx = for(ever) { - # qmake variables cannot contain dashes, so normalize the names first - CLEAN_QT$$var_sfx = $$replace(QT$$var_sfx, -private$, _private) # Topological resolution of modules based on their QT..depends variable FULL_QT$$var_sfx = $$resolve_depends(CLEAN_QT$$var_sfx, "QT.") # Finally actually add the modules @@ -167,9 +249,6 @@ for(ever) { message("This is not a bug, but a result of using Qt internals. You have been warned!") } -qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE -all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") - !no_qt_rpath:!static:qtConfig(rpath):!qtConfig(static):\ contains(all_qt_module_deps, core) { relative_qt_rpath:!isEmpty(QMAKE_REL_RPATH_BASE):contains(INSTALLS, target):\ @@ -243,66 +322,7 @@ contains(all_qt_module_deps, qml): \ QMAKE_DISTCLEAN += $$QML_IMPORT_CPP } } - -!import_qpa_plugin { - warning("CONFIG-=import_qpa_plugin is deprecated. Use QTPLUGIN.platforms=- instead.") - QTPLUGIN.platforms = - -} else: qpa_minimal_plugin { - warning("CONFIG+=qpa_minimal_plugin is deprecated. Use QTPLUGIN.platforms=qminimal instead.") - QTPLUGIN.platforms = qminimal -} - -import_plugins { - autoplugs = - for (qtmod, all_qt_module_deps) { - for (ptype, QT.$${qtmod}.plugin_types) { - nptype = $$replace(ptype, [-/], _) - isEmpty(QTPLUGIN.$$nptype) { - for (plug, QT_PLUGINS) { - equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { - for (dep, QT_PLUGIN.$${plug}.EXTENDS) { - !contains(all_qt_module_deps, $$dep) { - plug = - break() - } - } - autoplugs += $$plug - } - } - } else { - plug = $$eval(QTPLUGIN.$$nptype) - !equals(plug, -): \ - autoplugs += $$plug - } - } - } - manualplugs = $$QTPLUGIN - manualplugs -= $$autoplugs - QTPLUGIN -= $$manualplugs - !isEmpty(QTPLUGIN): \ - warning("Redundant entries in QTPLUGIN: $$QTPLUGIN") - QTPLUGIN = $$manualplugs $$autoplugs -} - qtConfig(static) { - import_plugins:!isEmpty(QTPLUGIN) { - IMPORT_FILE_CONT = \ - "// This file is autogenerated by qmake. It imports static plugin classes for" \ - "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS. variables." \ - "$${LITERAL_HASH}include " - for(IMPORT_PLUG, $$list($$unique(QTPLUGIN))) { - PLUG_CLASS = $$eval(QT_PLUGIN.$${IMPORT_PLUG}.CLASS_NAME) - !isEmpty(PLUG_CLASS): \ - IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$PLUG_CLASS)" - else: \ - warning("Plugin class name could not be determined for $$IMPORT_PLUG plugin.") - } - IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_import.cpp - write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() - GENERATED_SOURCES += $$IMPORT_CPP - QMAKE_DISTCLEAN += $$IMPORT_CPP - } - for (QTPLUG, $$list($$lower($$unique(QTPLUGIN)))) { # Check if the plugin is known to Qt. We can use this to determine # the plugin path. Unknown plugins must rely on the default link path. -- cgit v1.2.3