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 <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
1e147f446a
commit
23bce6b169
@ -1952,7 +1952,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
||||
char buff[256];
|
||||
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
|
||||
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
||||
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
||||
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
||||
QString indeps;
|
||||
while(!feof(proc)) {
|
||||
int read_in = (int)fread(buff, 1, 255, proc);
|
||||
@ -2044,7 +2044,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
|
||||
char buff[256];
|
||||
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, out, LocalShell);
|
||||
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd);
|
||||
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
||||
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
||||
QString indeps;
|
||||
while(!feof(proc)) {
|
||||
int read_in = (int)fread(buff, 1, 255, proc);
|
||||
|
@ -46,9 +46,11 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
#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
|
||||
|
||||
|
@ -2327,7 +2327,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
|
||||
dep_cmd.prepend(QLatin1String("cd ")
|
||||
+ Project->escapeFilePath(Option::fixPathToLocalOS(Option::output_dir, false))
|
||||
+ QLatin1String(" && "));
|
||||
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
||||
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
||||
QString indeps;
|
||||
while(!feof(proc)) {
|
||||
int read_in = (int)fread(buff, 1, 255, proc);
|
||||
|
@ -1618,7 +1618,7 @@ void VcprojGenerator::initResourceFiles()
|
||||
dep_cmd.prepend(QLatin1String("cd ")
|
||||
+ escapeFilePath(Option::fixPathToLocalOS(Option::output_dir, false))
|
||||
+ QLatin1String(" && "));
|
||||
if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) {
|
||||
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
|
||||
QString indeps;
|
||||
while(!feof(proc)) {
|
||||
int read_in = (int)fread(buff, 1, 255, proc);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -64,9 +64,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
|
||||
|
||||
@ -307,7 +309,7 @@ bool QMakeGlobals::initProperties()
|
||||
data = proc.readAll();
|
||||
#else
|
||||
if (FILE *proc = QT_POPEN(QString(QMakeInternal::IoUtils::shellQuote(qmake_abslocation)
|
||||
+ QLatin1String(" -query")).toLocal8Bit(), "r")) {
|
||||
+ QLatin1String(" -query")).toLocal8Bit(), QT_POPEN_READ)) {
|
||||
char buff[1024];
|
||||
while (!feof(proc))
|
||||
data.append(buff, int(fread(buff, 1, 1023, proc)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user