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>
This commit is contained in:
parent
1face78345
commit
4041610cb2
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user