From 630d3328ddc35a02c42fa6501636eaee6eb76a37 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Tue, 12 Sep 2023 15:09:05 +0200 Subject: [PATCH] Iterate over all extraPrefixDirs when collecting "directories" When collecting plugins required for the android application according to linked targets we should take into account all prefix directories. But not only the first one. Otherwise the order we use when adding paths to extraPrefixDirs will affect collecting of the plugins. This specifically leads to the issue if the user project builds custom Qt plugins. The plugin directory from user project build tree will be found first and all plugins from Qt installation directory are discarded. Pick-to: 6.6 6.5 Fixes: QTBUG-116920 Change-Id: Id94ebaf5ccd1a279a74b38b59ff535f45230e1b4 Reviewed-by: Assam Boudjelthia Reviewed-by: Alexandru Croitor --- src/tools/androiddeployqt/main.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index cba1dc61fed..134f8b2db56 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -1849,14 +1849,31 @@ QList findFilesRecursively(const Options &options, const QFileInfo QList findFilesRecursively(const Options &options, const QString &fileName) { + // We try to find the fileName in extraPrefixDirs first. The function behaves differently + // depending on what the fileName points to. If fileName is a file then we try to find the + // first occurrence in extraPrefixDirs and return this file. If fileName is directory function + // iterates over it and looks for deployment artifacts in each 'extraPrefixDirs' entry. + // Also we assume that if the fileName is recognized as a directory once it will be directory + // for every 'extraPrefixDirs' entry. + QList deps; for (const auto &prefix : options.extraPrefixDirs) { QFileInfo info(prefix + u'/' + fileName); - if (info.exists()) - return findFilesRecursively(options, info, prefix + u'/'); + if (info.exists()) { + if (info.isDir()) + deps.append(findFilesRecursively(options, info, prefix + u'/')); + else + return findFilesRecursively(options, info, prefix + u'/'); + } } - QFileInfo info(options.qtInstallDirectory + "/"_L1 + fileName); - QFileInfo rootPath(options.qtInstallDirectory + "/"_L1); - return findFilesRecursively(options, info, rootPath.absolutePath() + u'/'); + + // Usually android deployment settings contain Qt install directory in extraPrefixDirs. + if (std::find(options.extraPrefixDirs.begin(), options.extraPrefixDirs.end(), + options.qtInstallDirectory) == options.extraPrefixDirs.end()) { + QFileInfo info(options.qtInstallDirectory + "/"_L1 + fileName); + QFileInfo rootPath(options.qtInstallDirectory + "/"_L1); + deps.append(findFilesRecursively(options, info, rootPath.absolutePath())); + } + return deps; } bool readAndroidDependencyXml(Options *options,