From 247693f3413707d4b9741defd996a0f9c9683cda Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 9 Jun 2022 13:13:49 +0200 Subject: [PATCH] androiddeployqt: Only pass qt_install_dir/qml directory if it exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Conan's case, the qtbase installed package directory lacks a qml directory. We pass that as a valid qml import path via CMake -> deployment json file -> androiddeployqt -> qmlimportscanner which causes the qmlimportscanner to fail with qmlimportscanner: No such file or directory: "~/package/some_sha_1/qml" Invalid json output from qmlimportscanner. which in turn fails the androiddeploqt build step. Make sure to only pass qtbase_install_dir/qml if it actually exists. Amends 4ef3da04c3390f02bcb0507128372e6a299dc8fd Amends c08b9a49ba70b1cbb0704668dd3f2c487d7f585e Fixes: QTBUG-104056 Task-number: QTBUG-88519 Task-number: QTBUG-89588 Change-Id: I4310eb4e265ae8d3e3f09e1e1dbed79210e23de6 Reviewed-by: Alexey Edelev Reviewed-by: Qt CI Bot (cherry picked from commit 0c82f98ec5c0135f3789f0f9c5e30978698ddff9) Reviewed-by: Jörg Bornemann --- src/tools/androiddeployqt/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 9f7ab72f0bf..d45a4a5784f 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -1892,12 +1892,22 @@ bool scanImports(Options *options, QSet *usedDependencies) #endif QStringList importPaths; - importPaths += shellQuote(options->qtInstallDirectory + QLatin1String("/qml")); + // In Conan's case, qtInstallDirectory will point only to qtbase installed files, which + // lacks a qml directory. We don't want to pass it as an import path if it doesn't exist + // because it will cause qmlimportscanner to fail. + // This also covers the case when only qtbase is installed in a regular Qt build. + const QString mainImportPath = options->qtInstallDirectory + QLatin1String("/qml"); + if (QDir().exists(mainImportPath)) + importPaths += shellQuote(mainImportPath); + + // These are usually provided by CMake in the deployment json file from paths specified + // in CMAKE_FIND_ROOT_PATH. They might not have qml modules. for (const QString &prefix : options->extraPrefixDirs) if (QDir().exists(prefix + QLatin1String("/qml"))) importPaths += shellQuote(prefix + QLatin1String("/qml")); + // These are provided by both CMake and qmake. for (const QString &qmlImportPath : qAsConst(options->qmlImportPaths)) { if (QDir().exists(qmlImportPath)) { importPaths += shellQuote(qmlImportPath);