qmake: Escape trailing backslash for OBJECTS_DIR for MinGW
qmake automatically appends a dir_sep to a few directory paths (see MakefileGenerator::initOutPaths), and various .pri and .prf files rely on that. Anyhow, for non-MSys MinGW on Windows this creates a problem, because mingw32-make will interpret the backslash in OBJECTS_DIR = some_path\ to escape the following newline. We have been working around this problem in various ways: - winmakefile.cpp just removes the trailing \ for OBJECTS_DIR, at the cost of not being compatible with logic in .prf/.pri files that rely on the separator. - winmakefile.cpp adds a '#avoid trailing-slash linebreak' comment for DESTDIR. Anyhow, this does not seem to work for mingw32-make: If you reference $(DESTDIR), the variable will contain trailing spaces. - unixmakefile2.cpp duplicates a trailing \ for DESTDIR. The last approach is now taken also for OBJECTS_DIR. Task-number: QTBUG-75257 Change-Id: Ie8171a990a9ce1cfbf1b94037252ef2392313338 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
9dbbccf7a2
commit
bac2b0ef36
@ -169,6 +169,16 @@ static QString rfc1034Identifier(const QString &str)
|
||||
return s;
|
||||
}
|
||||
|
||||
static QString escapeDir(const QString &dir)
|
||||
{
|
||||
// When building on non-MSys MinGW, the path ends with a backslash, which
|
||||
// GNU make will interpret that as a line continuation. Doubling the backslash
|
||||
// avoids the problem, at the cost of the variable containing *both* backslashes.
|
||||
if (dir.endsWith('\\'))
|
||||
return dir + '\\';
|
||||
return dir;
|
||||
}
|
||||
|
||||
void
|
||||
UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
{
|
||||
@ -231,7 +241,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
t << "####### Output directory\n\n";
|
||||
// This is used in commands by some .prf files.
|
||||
if (! project->values("OBJECTS_DIR").isEmpty())
|
||||
t << "OBJECTS_DIR = " << fileVar("OBJECTS_DIR") << endl;
|
||||
t << "OBJECTS_DIR = " << escapeDir(fileVar("OBJECTS_DIR")) << endl;
|
||||
else
|
||||
t << "OBJECTS_DIR = ./\n";
|
||||
t << endl;
|
||||
@ -277,13 +287,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
t << "DIST = " << valList(fileFixify(project->values("DISTFILES").toQStringList())) << " "
|
||||
<< fileVarList("HEADERS") << ' ' << fileVarList("SOURCES") << endl;
|
||||
t << "QMAKE_TARGET = " << fileVar("QMAKE_ORIG_TARGET") << endl;
|
||||
QString destd = fileVar("DESTDIR");
|
||||
// When building on non-MSys MinGW, the path ends with a backslash, which
|
||||
// GNU make will interpret that as a line continuation. Doubling the backslash
|
||||
// avoids the problem, at the cost of the variable containing *both* backslashes.
|
||||
if (destd.endsWith('\\'))
|
||||
destd += '\\';
|
||||
t << "DESTDIR = " << destd << endl;
|
||||
t << "DESTDIR = " << escapeDir(fileVar("DESTDIR")) << endl;
|
||||
t << "TARGET = " << fileVar("TARGET") << endl;
|
||||
if(project->isActiveConfig("plugin")) {
|
||||
t << "TARGETD = " << fileVar("TARGET") << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user