MinGW: Use a response file for long include paths

Change-Id: I55ce73ad08473bca27c7ab5730f633fb77c9b8cd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Orgad Shaneh 2020-06-05 18:59:01 +03:00 committed by Orgad Shaneh
parent 1f0299b029
commit 4c20a35cd9
3 changed files with 28 additions and 7 deletions

View File

@ -3456,7 +3456,10 @@ ProKey MakefileGenerator::fullTargetVariable() const
return "TARGET";
}
QString MakefileGenerator::createResponseFile(const QString &baseName, const ProStringList &objList)
QString MakefileGenerator::createResponseFile(
const QString &baseName,
const ProStringList &objList,
const QString &prefix)
{
QString fileName = baseName + '.' + fileVar("QMAKE_ORIG_TARGET");
if (!var("BUILD_NAME").isEmpty())
@ -3479,7 +3482,7 @@ QString MakefileGenerator::createResponseFile(const QString &baseName, const Pro
.replace(QLatin1Char('\t'), QLatin1String("\\\t"))
.replace(QLatin1Char('"'), QLatin1String("\\\""))
.replace(QLatin1Char('\''), QLatin1String("\\'"));
t << path << Qt::endl;
t << prefix << path << Qt::endl;
}
t.flush();
file.close();

View File

@ -36,6 +36,7 @@
#include <qlist.h>
#include <qhash.h>
#include <qfileinfo.h>
#include <functional>
QT_BEGIN_NAMESPACE
@ -264,7 +265,9 @@ protected:
QStringView fixedBase, int slashOff);
bool processPrlFileCore(QString &origFile, QStringView origName,
const QString &fixedFile);
QString createResponseFile(const QString &baseName, const ProStringList &objList);
QString createResponseFile(const QString &baseName,
const ProStringList &objList,
const QString &prefix = QString());
public:
QMakeProject *projectFile() const;

View File

@ -201,11 +201,26 @@ void MingwMakefileGenerator::writeIncPart(QTextStream &t)
t << "INCPATH = ";
const ProStringList &incs = project->values("INCLUDEPATH");
for (ProStringList::ConstIterator incit = incs.begin(); incit != incs.end(); ++incit) {
QString inc = (*incit).toQString();
QFile responseFile;
QTextStream responseStream;
QChar sep(' ');
int totalLength = std::accumulate(incs.constBegin(), incs.constEnd(), 0,
[](int total, const ProString &inc) {
return total + inc.size() + 2;
});
if (totalLength > project->intValue("QMAKE_RESPONSEFILE_THRESHOLD", 8000)) {
const QString fileName = createResponseFile("incpath", incs, "-I");
if (!fileName.isEmpty()) {
t << '@' + fileName;
t << Qt::endl;
return;
}
}
for (const ProString &incit: qAsConst(incs)) {
QString inc = incit.toQString();
inc.replace(QRegularExpression("\\\\$"), "");
t << "-I" << escapeFilePath(inc) << ' ';
inc.replace('\\', '/');
t << "-I" << escapeFilePath(inc) << sep;
}
t << Qt::endl;
}