aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-03-25 12:19:11 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2021-03-25 15:33:27 +0100
commit93984dfc86828b0e52fdc6580f46e361a56183bc (patch)
tree658d1bdab125fe4bbe751acb65a6abb01585d853 /tools
parenteb74d99d02f61007443bcdf83033b05d525326b8 (diff)
qmllint: Only exclude default QML import dirs when explicitly requested
Previously specifying any additional QML import directories would lead to the default directories to be excluded. This can be useful if you want to run qmllint on a project using a different Qt version but this is not behavior you want in most cases. [ChangeLog][qmllint][Important Behavior Change] Using -I no longer excludes default QML import directories. Use --bare to get the old behavior. Change-Id: I2ca5789cd44306bcad54f7b1b82049c21f721d3d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmllint/main.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/qmllint/main.cpp b/tools/qmllint/main.cpp
index 3fb9e9c324..64388c78ae 100644
--- a/tools/qmllint/main.cpp
+++ b/tools/qmllint/main.cpp
@@ -148,6 +148,12 @@ int main(int argv, char *argc[])
QLatin1String("directory"));
parser.addOption(qmlImportPathsOption);
+ QCommandLineOption qmlImportNoDefault(
+ QStringList() << "bare",
+ QLatin1String("Do not include default import directories or the current directory. "
+ "This may be used to run qmllint on a project using a different Qt version."));
+ parser.addOption(qmlImportNoDefault);
+
QCommandLineOption qmltypesFilesOption(
QStringList() << "i"
<< "qmltypes",
@@ -173,15 +179,18 @@ int main(int argv, char *argc[])
bool warnWithStatement = !parser.isSet(disableCheckWithStatement);
bool warnInheritanceCycle = !parser.isSet(disableCheckInheritanceCycle);
- // use host qml import path as a sane default if nothing else has been provided
- QStringList qmlImportPaths = parser.isSet(qmlImportPathsOption)
- ? parser.values(qmlImportPathsOption)
+ // use host qml import path as a sane default if not explicitly disabled
+ QStringList qmlImportPaths = parser.isSet(qmlImportNoDefault)
+ ? QStringList {}
# ifndef QT_BOOTSTRAPPED
: QStringList { QLibraryInfo::path(QLibraryInfo::QmlImportsPath), QDir::currentPath() };
# else
: QStringList { QDir::currentPath() };
# endif
+ if (parser.isSet(qmlImportPathsOption))
+ qmlImportPaths << parser.values(qmlImportPathsOption);
+
QStringList qmltypesFiles;
if (parser.isSet(qmltypesFilesOption)) {
qmltypesFiles = parser.values(qmltypesFilesOption);