diff options
author | Craig Scott <craig.scott@qt.io> | 2021-07-06 17:27:11 +1000 |
---|---|---|
committer | Craig Scott <craig.scott@qt.io> | 2021-07-07 12:07:48 +1000 |
commit | 7365b0d1c64fcde54ae5a043b28550f44797d236 (patch) | |
tree | e4a8f9bd4574e54d79df5611eb58d76c4907ae73 /tools/qmllint/main.cpp | |
parent | b49859528da852e2dd3b89af5ed768bf903f58ef (diff) |
CMake: Run qmllint on the qml files in the source tree
In order to use the source tree files, qmllint needs to know where they
will end up in the resource system. The source files could be at any
arbitrary location and have their resource path set by a
QT_RESOURCE_ALIAS source file property. Therefore, we have to give the
generated .qrc files to qmllint so it can work out where each source
file will end up.
The qmllint command previously only supported a single --resource
option, but now we need to potentially pass more than one .qrc file.
Extend qmllint to allow multiple --resource options to be given, in
the same way that multiple -I options can be given.
Task-number: QTBUG-94761
Pick-to: 6.2
Change-Id: Ibeb6541e1f54bea6eeeccd07426dd238b0459ff2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Diffstat (limited to 'tools/qmllint/main.cpp')
-rw-r--r-- | tools/qmllint/main.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp index bfd990fe5b..d86fc55de0 100644 --- a/tools/qmllint/main.cpp +++ b/tools/qmllint/main.cpp @@ -61,7 +61,7 @@ constexpr int JSON_LOGGING_FORMAT_REVISION = 1; static bool lint_file(const QString &filename, const bool silent, QJsonArray *json, const QStringList &qmlImportPaths, const QStringList &qmltypesFiles, - const QString &resourceFile, + const QStringList &resourceFiles, const QMap<QString, QQmlJSLogger::Option> &options, QQmlJSImporter &importer) { QJsonArray warnings; @@ -189,10 +189,10 @@ static bool lint_file(const QString &filename, const bool silent, QJsonArray *js } }; - if (resourceFile.isEmpty()) { + if (resourceFiles.isEmpty()) { check(nullptr); } else { - QQmlJSResourceFileMapper mapper({ resourceFile }); + QQmlJSResourceFileMapper mapper(resourceFiles); check(&mapper); } } @@ -352,11 +352,11 @@ All warnings can be set to three levels: } } - QString resourceFile; + QStringList resourceFiles; if (parser.isSet(resourceOption)) - resourceFile = parser.value(resourceOption); + resourceFiles << parser.values(resourceOption); else if (settings.isSet(resourceSetting)) - resourceFile = settings.value(resourceSetting).toString(); + resourceFiles << settings.value(resourceSetting).toStringList(); #else bool silent = false; @@ -364,8 +364,9 @@ All warnings can be set to three levels: bool warnUnqualified = true; bool warnWithStatement = true; bool warnInheritanceCycle = true; - QStringList qmlImportPahs {}; + QStringList qmlImportPaths {}; QStringList qmltypesFiles {}; + QStringList resourceFiles {}; #endif bool success = true; QQmlJSImporter importer(qmlImportPaths, nullptr); @@ -383,7 +384,7 @@ All warnings can be set to three levels: for (const QString &filename : arguments) { #endif success &= lint_file(filename, silent, useJson ? &jsonFiles : nullptr, qmlImportPaths, - qmltypesFiles, resourceFile, options, importer); + qmltypesFiles, resourceFiles, options, importer); } if (useJson) { |