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
Pick-to: 6.4 6.3
Change-Id: I8af76bd38cd55700e17794cf2fff0e50a90ac87e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Moody Liu 2022-05-18 01:17:56 +01:00
parent aefb5c5a56
commit 8a96c8a22c

View File

@ -1927,7 +1927,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<QString> *usedDependencies)
{
@ -2065,7 +2066,9 @@ bool scanImports(Options *options, QSet<QString> *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;
@ -2157,10 +2160,12 @@ bool scanImports(Options *options, QSet<QString> *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;