summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2021-01-28 21:21:44 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2021-06-07 18:40:27 +0000
commitc08b9a49ba70b1cbb0704668dd3f2c487d7f585e (patch)
treed875d21ef270c0e422ae67329c8912ca902347fa /src/tools
parent1365a1c7a76a73838909d63acb60ebdfcbdff62e (diff)
Android: don't call qmlimportscanner if no qml dir exist
If only qtbase is installed, androiddeployqt might call qmlimportscanner which will fail to find a qml dir under the Qt install path. Thus, we check if the qml dir exists before calling qmlimportscanner otherwise throw a warning. Fixes: QTBUG-89588 Change-Id: I706eb2a233e9ab5b250652cd46aae75cab178648 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/androiddeployqt/main.cpp52
1 files changed, 38 insertions, 14 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index b3b7b169ca..5872b8e829 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -1838,17 +1838,7 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
qmlImportScanner += QLatin1String(".exe");
#endif
- if (!QFile::exists(qmlImportScanner)) {
- fprintf(stderr, "qmlimportscanner not found: %s\n", qPrintable(qmlImportScanner));
- return true;
- }
-
QString rootPath = options->rootPath;
- if (!options->qrcFiles.isEmpty()) {
- qmlImportScanner += QLatin1String(" -qrcFiles");
- for (const QString &qrcFile : options->qrcFiles)
- qmlImportScanner += QLatin1Char(' ') + shellQuote(qrcFile);
- }
if (rootPath.isEmpty())
rootPath = QFileInfo(options->inputFileName).absolutePath();
@@ -1858,12 +1848,9 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
if (!rootPath.endsWith(QLatin1Char('/')))
rootPath += QLatin1Char('/');
- qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath));
-
QStringList importPaths;
importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml"));
- if (!rootPath.isEmpty())
- importPaths += shellQuote(rootPath);
+
for (const QString &prefix : options->extraPrefixDirs)
if (QDir().exists(prefix + QLatin1String("/qml")))
importPaths += shellQuote(prefix + QLatin1String("/qml"));
@@ -1876,6 +1863,43 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
qPrintable(qmlImportPath));
}
}
+
+ bool qmlImportExists = false;
+
+ for (const QString &import : importPaths) {
+ if (QDir().exists(import)) {
+ qmlImportExists = true;
+ break;
+ }
+ }
+
+ // Check importPaths without rootPath, since we need at least one qml plugins
+ // folder to run a QML file
+ if (!qmlImportExists) {
+ fprintf(stderr, "Warning: no 'qml' directory found under Qt install directory "
+ "or import paths. Skipping QML dependency scanning.\n");
+ return true;
+ }
+
+ if (!QFile::exists(qmlImportScanner)) {
+ fprintf(stderr, "%s: qmlimportscanner not found at %s\n",
+ qmlImportExists ? QLatin1String("Error").data() : QLatin1String("Warning").data(),
+ qPrintable(qmlImportScanner));
+ return true;
+ }
+
+ // After checking for qml folder imports we can add rootPath
+ if (!rootPath.isEmpty())
+ importPaths += shellQuote(rootPath);
+
+ qmlImportScanner += QLatin1String(" -rootPath %1").arg(shellQuote(rootPath));
+
+ if (!options->qrcFiles.isEmpty()) {
+ qmlImportScanner += QLatin1String(" -qrcFiles");
+ for (const QString &qrcFile : options->qrcFiles)
+ qmlImportScanner += QLatin1Char(' ') + shellQuote(qrcFile);
+ }
+
qmlImportScanner += QLatin1String(" -importPath %1").arg(importPaths.join(QLatin1Char(' ')));
if (options->verbose) {