Check if QML plugin has the embedded QML files before copying to the Android bundle

We can detect if QML module has the embedded into the plugin QML files
using the 'prefer' record from qmldir files. No need to duplicate QML
files inside the android_rcc_bundle if 'prefer' record starts
with ':/'.

Pick-to: 6.3
Fixes: QTBUG-95984
Change-Id: Iee4f2248e3c0239c4f95a5db6e8fb3f16be636c5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Alexey Edelev 2021-12-08 19:26:29 +01:00
parent 153ded9b95
commit bde2764ab0

View File

@ -2131,24 +2131,30 @@ bool scanImports(Options *options, QSet<QString> *usedDependencies)
collectQmlDependency(qmldirFileInfo.absoluteFilePath());
}
QVariantList qmlFiles =
object.value(QLatin1String("components")).toArray().toVariantList();
qmlFiles.append(object.value(QLatin1String("scripts")).toArray().toVariantList());
bool qmlFilesMissing = false;
for (const auto &qmlFileEntry : qmlFiles) {
QFileInfo fileInfo(qmlFileEntry.toString());
if (!fileInfo.exists()) {
qmlFilesMissing = true;
break;
QString prefer = object.value(QLatin1String("prefer")).toString();
// If the preferred location of Qml files points to the Qt resources, this means
// that all Qml files has been embedded into plugin and we should not copy them to the
// android rcc bundle
if (!prefer.startsWith(QLatin1String(":/"))) {
QVariantList qmlFiles =
object.value(QLatin1String("components")).toArray().toVariantList();
qmlFiles.append(object.value(QLatin1String("scripts")).toArray().toVariantList());
bool qmlFilesMissing = false;
for (const auto &qmlFileEntry : qmlFiles) {
QFileInfo fileInfo(qmlFileEntry.toString());
if (!fileInfo.exists()) {
qmlFilesMissing = true;
break;
}
collectQmlDependency(fileInfo.absoluteFilePath());
}
collectQmlDependency(fileInfo.absoluteFilePath());
}
if (qmlFilesMissing) {
if (options->verbose)
fprintf(stdout,
" -- Skipping because the required qml files are missing.\n");
continue;
if (qmlFilesMissing) {
if (options->verbose)
fprintf(stdout,
" -- Skipping because the required qml files are missing.\n");
continue;
}
}
options->qtDependencies[options->currentArchitecture].append(qmlImportsDependencies);