summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2020-06-01 19:48:50 +0300
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2020-06-18 12:17:34 +0000
commit4041610cb202699a47268975e5aaecaa1f182c0a (patch)
treef86b5475d0889c44da6af68eb03353bab9af1c24
parent1face783456582b805acc32452b5d61ddc3f99f7 (diff)
Android: warn about too long build paths on Windows
If Gradle build fails on Windows, check for java files that exceed the max length of 260 that Gradle can handle, then warn about the length issue. Pick-to: 5.15 Task-number: QTBUG-83875 Change-Id: Ia7462bc816b3efa4ba9fdd0f179fdc4c06e23248 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--src/tools/androiddeployqt/main.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp
index 5e12dc059b..70353ee148 100644
--- a/src/tools/androiddeployqt/main.cpp
+++ b/src/tools/androiddeployqt/main.cpp
@@ -44,6 +44,10 @@
#include <algorithm>
+#if defined(Q_OS_WIN32)
+#include <qt_windows.h>
+#endif
+
#ifdef Q_CC_MSVC
#define popen _popen
#define QT_POPEN_READ "rb"
@@ -2326,6 +2330,27 @@ static bool mergeGradleProperties(const QString &path, GradleProperties properti
return true;
}
+#if defined(Q_OS_WIN32)
+void checkAndWarnGradleLongPaths(const QString &outputDirectory)
+{
+ QStringList longFileNames;
+ QDirIterator it(outputDirectory, QStringList(QStringLiteral("*.java")), QDir::Files,
+ QDirIterator::Subdirectories);
+ while (it.hasNext()) {
+ if (it.next().size() >= MAX_PATH)
+ longFileNames.append(it.next());
+ }
+
+ if (!longFileNames.isEmpty()) {
+ fprintf(stderr,
+ "The maximum path length that can be processed by Gradle on Windows is %d characters.\n"
+ "Consider moving your project to reduce its path length.\n"
+ "The following files have too long paths:\n%s.\n",
+ MAX_PATH, qPrintable(longFileNames.join(QLatin1Char('\n'))));
+ }
+}
+#endif
+
bool buildAndroidProject(const Options &options)
{
GradleProperties localProperties;
@@ -2390,6 +2415,10 @@ bool buildAndroidProject(const Options &options)
fprintf(stderr, "Building the android package failed!\n");
if (!options.verbose)
fprintf(stderr, " -- For more information, run this command with --verbose.\n");
+
+#if defined(Q_OS_WIN32)
+ checkAndWarnGradleLongPaths(options.outputDirectory);
+#endif
return false;
}