diff options
author | Craig Scott <craig.scott@qt.io> | 2021-08-16 15:10:38 +1000 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-20 18:06:28 +0200 |
commit | 96fdbf597e581fe5e09e02758a4a2b0fe12add53 (patch) | |
tree | 6cadc070ed6473b16cf9a99bb73f5849ddc59d1f /tools | |
parent | 86a477e72be6a71f50213e5ac2841eba0b4e78b4 (diff) |
Allow QML plugin's CMake target name to be specified for qmldir file
The current code assumes that the basename of the QML plugin is the
same as the CMake target it corresponds to. This won't be the case for
installed Qt packages due to the installed name including a namespace.
It also won't match when a Qt library infix is used. The current code
works around the former by trying to heuristically work out whether
a namespaced Qt target exists for the plugin. The Qt library infix is
more problematic because the plugin target name won't include the
infix whereas the plugin library basename will.
Address both of those issues by adding an internal option
INSTALLED_PLUGIN_TARGET to qt6_add_qml_module() which allows the
installed target name to be provided. When included in a qmldir file,
qt6_import_qml_plugin() will use that name, otherwise it will fall
back to using the plugin library's basename, as per the current
behavior. The option may become public in the future, but for now it
is only for Qt's internal use for the 6.2 release.
Conflicts:
src/qml/qmldirparser/qqmldirparser_p.h
Fixes: QTBUG-95140
Change-Id: I5a057c80b70ee802c0f0840e9eea2e579193d126
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit a25f650c317e4886007a8beb0e9f2f7e973e6e7c)
Reviewed-by: Craig Scott <craig.scott@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlimportscanner/main.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index d59dc4a2e1..ab26abae46 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -69,6 +69,10 @@ inline QString dependenciesLiteral() { return QStringLiteral("dependencies"); } inline QString moduleLiteral() { return QStringLiteral("module"); } inline QString javascriptLiteral() { return QStringLiteral("javascript"); } inline QString directoryLiteral() { return QStringLiteral("directory"); } +inline QString linkTargetLiteral() +{ + return QStringLiteral("linkTarget"); +} void printUsage(const QString &appNameIn) { @@ -193,6 +197,10 @@ QVariantMap pluginsForModulePath(const QString &modulePath, const QString &versi pluginInfo[pluginIsOptionalLiteral()] = true; } + if (!parser.linkTarget().isEmpty()) { + pluginInfo[linkTargetLiteral()] = parser.linkTarget(); + } + pluginInfo[classnamesLiteral()] = parser.classNames().join(QLatin1Char(' ')); QStringList importsAndDependencies; @@ -310,9 +318,12 @@ QVariantList findPathsForModuleImports(const QVariantList &imports) import.insert(relativePathLiteral(), paths.second); plugininfo = pluginsForModulePath(paths.first, version); } + QString linkTarget = plugininfo.value(linkTargetLiteral()).toString(); QString plugins = plugininfo.value(pluginsLiteral()).toString(); bool isOptional = plugininfo.value(pluginIsOptionalLiteral(), QVariant(false)).toBool(); QString classnames = plugininfo.value(classnamesLiteral()).toString(); + if (!linkTarget.isEmpty()) + import.insert(linkTargetLiteral(), linkTarget); if (!plugins.isEmpty()) import.insert(QStringLiteral("plugin"), plugins); if (isOptional) |