aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlimportscanner/main.cpp
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-08-16 15:10:38 +1000
committerCraig Scott <craig.scott@qt.io>2021-08-20 09:29:30 +1000
commita25f650c317e4886007a8beb0e9f2f7e973e6e7c (patch)
tree575ecdbf3bf260af31eef3c5df4adc45556d789b /tools/qmlimportscanner/main.cpp
parent30e6bb35e48207a994dd4e49ca999d45266a04f5 (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. Fixes: QTBUG-95140 Pick-to: 6.2 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>
Diffstat (limited to 'tools/qmlimportscanner/main.cpp')
-rw-r--r--tools/qmlimportscanner/main.cpp11
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)