From 6ebc4249e23a323a56245f046b5842cedb9e92fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Jul 2022 15:56:29 +0200 Subject: qmake: Split up logic for enumerating plugins from how they are processed Sanitizing the contents of the QTPLUGIN variable, and adding default plugins from the available modules, should be a separate step before the resulting QTPLUGIN is iterated and processed by for example linking to each plugin, generating an import file, and adding module dependencies. This makes it easier to add logic to the processing step later on. Change-Id: I00e826c7fe87b29cf2e6bf4e1901c4d1482a20e6 Reviewed-by: Alexandru Croitor --- mkspecs/features/qt.prf | 56 ++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'mkspecs') diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index d0f82dc99c..d08cf264a8 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -75,13 +75,15 @@ all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_d QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN))) +# Sanitize requested plugins, and add any default plugins 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 + all_plugin_deps = $$all_qt_module_deps + plugin_deps = $$all_plugin_deps for(ever) { - # Automatically link the default plugins for the linked Qt modules. + # Automatically add the default plugins for the linked Qt modules. for (qtmod, plugin_deps) { for (ptype, QT.$${qtmod}.plugin_types) { nptype = $$replace(ptype, [-/], _) @@ -89,7 +91,7 @@ import_plugins:qtConfig(static) { for (plug, QT_PLUGINS) { equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) { for (dep, QT_PLUGIN.$${plug}.EXTENDS) { - !contains(all_qt_module_deps, $$dep) { + !contains(all_plugin_deps, $$dep) { plug = break() } @@ -112,44 +114,39 @@ import_plugins:qtConfig(static) { 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 + plugin_deps -= $$all_plugin_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 + all_plugin_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'.") - } - TARGET_BASENAME = $$lower($$basename(TARGET)) - TARGET_BASENAME ~= s/\s/_/g - - IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp - write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() - GENERATED_SOURCES += $$IMPORT_CPP - QMAKE_DISTCLEAN += $$IMPORT_CPP - } } # Only link against plugins in static builds !isEmpty(QTPLUGIN):qtConfig(static) { + 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'.") + + plugin_deps = $$eval(QT_PLUGIN.$${plug}.DEPENDS) + plugin_deps = $$resolve_depends(plugin_deps, "QT.", ".depends" ".run_depends") + all_qt_module_deps *= $$plugin_deps + # 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. plug_type = $$eval(QT_PLUGIN.$${plug}.TYPE) @@ -163,6 +160,13 @@ import_plugins:qtConfig(static) { LIBS += -l$${plug}$$qtPlatformTargetSuffix() } } + + TARGET_BASENAME = $$lower($$basename(TARGET)) + TARGET_BASENAME ~= s/\s/_/g + IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp + write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() + GENERATED_SOURCES += $$IMPORT_CPP + QMAKE_DISTCLEAN += $$IMPORT_CPP } # target variable, flag source variable -- cgit v1.2.3