From ec4149a240e9737287114c1e656873c91062192f Mon Sep 17 00:00:00 2001 From: Moody Liu Date: Wed, 18 May 2022 01:17:56 +0100 Subject: fix androiddeployqt with user application with in-tree QML modules when deploying user applications with QML modules located under user's subdirectories, (e.g. some third-party QML components used as git submomdule). The qmldir for such QML modules will be, typically, generated under BUILD_DIR/android-qml. if a BUILD_DIR is under the source directory, androiddeployqt will skip those QML modules incorrectly because they "appeared to be under the QML root path so that seems can be imported", however without deploying them, it's impossible to import those modules on an Android device. this patch adds a check that also tests if a root path plus the module's url can actually lead to the correct module path, so a QML module under android-qml subdir would not pass the test, and thus won't be skipped. Task-number: QTBUG-103593 Change-Id: I8af76bd38cd55700e17794cf2fff0e50a90ac87e Reviewed-by: Assam Boudjelthia (cherry picked from commit 8a96c8a22ca2c81969bb5e06249c06143b7f8249) Reviewed-by: Qt Cherry-pick Bot --- src/tools/androiddeployqt/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 8cdaf162ae..14a0b795a7 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -1930,7 +1930,8 @@ bool readDependenciesFromElf(Options *options, } bool goodToCopy(const Options *options, const QString &file, QStringList *unmetDependencies); -bool checkQmlFileInRootPaths(const Options *options, const QString &absolutePath); +bool checkCanImportFromRootPaths(const Options *options, const QString &absolutePath, + const QUrl &moduleUrl); bool scanImports(Options *options, QSet *usedDependencies) { @@ -2068,7 +2069,9 @@ bool scanImports(Options *options, QSet *usedDependencies) if (!absolutePath.endsWith(u'/')) absolutePath += u'/'; - if (checkQmlFileInRootPaths(options, absolutePath)) { + const QUrl url(object.value("name"_L1).toString()); + + if (checkCanImportFromRootPaths(options, info.absolutePath(), url)) { if (options->verbose) fprintf(stdout, " -- Skipping because path is in QML root path.\n"); continue; @@ -2160,10 +2163,12 @@ bool scanImports(Options *options, QSet *usedDependencies) return true; } -bool checkQmlFileInRootPaths(const Options *options, const QString &absolutePath) +bool checkCanImportFromRootPaths(const Options *options, const QString &absolutePath, + const QUrl &moduleUrl) { + const QString pathFromUrl = u"/"_s + moduleUrl.toString().replace(u'.', u'/'); for (auto rootPath : options->rootPaths) { - if (absolutePath.startsWith(rootPath)) + if ((rootPath + pathFromUrl) == absolutePath) return true; } return false; -- cgit v1.2.3