diff options
author | Kai Koehne <kai.koehne@qt.io> | 2019-05-09 10:42:03 +0200 |
---|---|---|
committer | Jani Heikkinen <jani.heikkinen@qt.io> | 2019-05-13 04:37:59 +0000 |
commit | bac2b0ef369503a9f00c503c1d8c5b12a496c3eb (patch) | |
tree | 1081f82d47a38a6f2ef90ead1921c68d59468f8f | |
parent | 9dbbccf7a2515c81842e80fb4d6bb3c3d82802b3 (diff) |
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>
-rw-r--r-- | qmake/generators/unix/unixmake2.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 7d8c70ec3b..b9de61fbc7 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -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; |