aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlimportscanner
diff options
context:
space:
mode:
authorAlexey Edelev <alexey.edelev@qt.io>2021-12-02 18:58:50 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-12-17 19:21:10 +0000
commit3919346c3a51960fa0ba3b8a4ef111feb2bee4f2 (patch)
tree7a13aed93d2593819ab190eaff0e933ad5087d8d /tools/qmlimportscanner
parentdbc134e207943b23edb90552a89d02b8f43812af (diff)
Add listing of the components and scripts that belongs to the qml module
Add qml components and scripts to the qmlimportscanner output to give information about files that actually belong to the qml module. Task-number: QTBUG-97834 Change-Id: I41394ba6fe9d9fe3af74786b4a802903849ae27d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 1d135de5cfef6da7457e5caf1612c0c112cfea7b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/qmlimportscanner')
-rw-r--r--tools/qmlimportscanner/main.cpp42
1 files changed, 38 insertions, 4 deletions
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 85542cbba8..c14fda2422 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -73,6 +73,8 @@ inline QString linkTargetLiteral()
{
return QStringLiteral("linkTarget");
}
+inline QString componentsLiteral() { return QStringLiteral("components"); }
+inline QString scriptsLiteral() { return QStringLiteral("scripts"); }
void printUsage(const QString &appNameIn)
{
@@ -218,15 +220,21 @@ QVariantMap pluginsForModulePath(const QString &modulePath, const QString &versi
}
QVariantList importsFromFiles;
+ QStringList componentFiles;
+ QStringList scriptFiles;
const auto components = parser.components();
for (const auto &component : components) {
+ const QString componentFullPath = modulePath + QLatin1Char('/') + component.fileName;
+ componentFiles.append(componentFullPath);
importsFromFiles
- += findQmlImportsInQmlFile(modulePath + QLatin1Char('/') + component.fileName);
+ += findQmlImportsInQmlFile(componentFullPath);
}
const auto scripts = parser.scripts();
for (const auto &script : scripts) {
+ const QString scriptFullPath = modulePath + QLatin1Char('/') + script.fileName;
+ scriptFiles.append(scriptFullPath);
importsFromFiles
- += findQmlImportsInJavascriptFile(modulePath + QLatin1Char('/') + script.fileName);
+ += findQmlImportsInJavascriptFile(scriptFullPath);
}
for (const QVariant &import : importsFromFiles) {
@@ -241,6 +249,10 @@ QVariantMap pluginsForModulePath(const QString &modulePath, const QString &versi
if (!importsAndDependencies.isEmpty())
pluginInfo[dependenciesLiteral()] = importsAndDependencies;
+ if (!componentFiles.isEmpty())
+ pluginInfo[componentsLiteral()] = componentFiles;
+ if (!scriptFiles.isEmpty())
+ pluginInfo[scriptsLiteral()] = scriptFiles;
return pluginInfo;
}
@@ -332,6 +344,8 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
QString plugins = plugininfo.value(pluginsLiteral()).toString();
bool isOptional = plugininfo.value(pluginIsOptionalLiteral(), QVariant(false)).toBool();
QString classnames = plugininfo.value(classnamesLiteral()).toString();
+ QStringList components = plugininfo.value(componentsLiteral()).toStringList();
+ QStringList scripts = plugininfo.value(scriptsLiteral()).toStringList();
if (!linkTarget.isEmpty())
import.insert(linkTargetLiteral(), linkTarget);
if (!plugins.isEmpty())
@@ -355,6 +369,14 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
importsCopy.append(depImport);
}
}
+ if (!components.isEmpty()) {
+ components.removeDuplicates();
+ import.insert(componentsLiteral(), components);
+ }
+ if (!scripts.isEmpty()) {
+ scripts.removeDuplicates();
+ import.insert(scriptsLiteral(), scripts);
+ }
}
import.remove(versionLiteral());
done.append(import);
@@ -585,8 +607,20 @@ QString generateCmakeIncludeFileContent(const QVariantList &importList) {
const QMap<QString, QVariant> &importDict = importVariant.toMap();
for (auto it = importDict.cbegin(); it != importDict.cend(); ++it) {
- s << it.key().toUpper() << QLatin1Char(';')
- << it.value().toString() << QLatin1Char(';');
+ s << it.key().toUpper() << QLatin1Char(';');
+ // QVariant can implicitly convert QString to the QStringList with the single
+ // element, let's use this.
+ QStringList args = it.value().toStringList();
+ if (args.isEmpty()) {
+ // This should not happen, but if it does, the result of the
+ // 'cmake_parse_arguments' call will be incorrect, so follow up semicolon
+ // indicates that the single-/multiarg option is empty.
+ s << QLatin1Char(';');
+ } else {
+ for (auto arg : args) {
+ s << arg << QLatin1Char(';');
+ }
+ }
}
s << QStringLiteral("\")\n");
++importsCount;