From 23bce6b169ca14ff72b672965ed5f89424c2d8fe Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Thu, 16 Jun 2016 14:38:22 +0100 Subject: qmake: Fix missing newlines in generated vcxproj files A bug in the Windows C Runtime causes text mode pipes to drop newlines sometimes. This bug was hidden because of another bug in rcc which caused newlines to be redundantly duplicated. When the latter bug was fixed (commit 53d5811b) the former bug was exposed, causing invalid vcxproj files to be generated. The Windows bug is described here: https://connect.microsoft.com/VisualStudio/feedback/details/1902345 The workaround is to avoid text mode, and do the conversion of "\r\n" to "\n" ourselves (which we were already doing anyway). Change-Id: I792599a4cd7822f109fa921f02207fb1b144b1d1 Reviewed-by: Oswald Buddenhagen --- qmake/library/qmakebuiltins.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qmake/library/qmakebuiltins.cpp') diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index 02cd8a2760..e200c7c551 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -72,9 +72,11 @@ #ifdef Q_OS_WIN32 #define QT_POPEN _popen +#define QT_POPEN_READ "rb" #define QT_PCLOSE _pclose #else #define QT_POPEN popen +#define QT_POPEN_READ "r" #define QT_PCLOSE pclose #endif @@ -413,7 +415,7 @@ QByteArray QMakeEvaluator::getCommandOutput(const QString &args) const #else if (FILE *proc = QT_POPEN(QString(QLatin1String("cd ") + IoUtils::shellQuote(QDir::toNativeSeparators(currentDirectory())) - + QLatin1String(" && ") + args).toLocal8Bit().constData(), "r")) { + + QLatin1String(" && ") + args).toLocal8Bit().constData(), QT_POPEN_READ)) { while (!feof(proc)) { char buff[10 * 1024]; int read_in = int(fread(buff, 1, sizeof(buff), proc)); @@ -423,6 +425,9 @@ QByteArray QMakeEvaluator::getCommandOutput(const QString &args) const } QT_PCLOSE(proc); } +# ifdef Q_OS_WIN + out.replace("\r\n", "\n"); +# endif #endif return out; } -- cgit v1.2.3