diff options
Diffstat (limited to 'qmake/generators/win32/msvc_objectmodel.cpp')
-rw-r--r-- | qmake/generators/win32/msvc_objectmodel.cpp | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 980e686..f5ca1be 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -280,6 +280,24 @@ inline XmlOutput::xml_output attrX(const char *name, const QStringList &v, const return attr(name, v.join(s)); } +// VCToolBase ------------------------------------------------- +QStringList VCToolBase::fixCommandLine(const QString &input) +{ + // The splitting regexp is a bit bizarre for backwards compat reasons (why else ...). + return input.split(QRegExp(QLatin1String("\n\t|\r\\\\h|\r\n"))); +} + +static QString vcCommandSeparator() +{ + // MSVC transforms the build tree into a single batch file, simply pasting the contents + // of the custom commands into it, and putting an "if errorlevel goto" statement behind it. + // As we want every sub-command to be error-checked (as is done by makefile-based + // backends), we insert the checks ourselves, using the undocumented jump target. + static QString cmdSep = + QLatin1String("
if errorlevel 1 goto VCReportError
"); + return cmdSep; +} + // VCCLCompilerTool ------------------------------------------------- VCCLCompilerTool::VCCLCompilerTool() : AssemblerOutput(asmListingNone), @@ -1913,36 +1931,11 @@ VCCustomBuildTool::VCCustomBuildTool() XmlOutput &operator<<(XmlOutput &xml, const VCCustomBuildTool &tool) { - // The code below offers two ways to split custom build step commands. - // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated - // in all generators. However, if you use $$escape_expand(\n\r) (or \n\h) instead, the VCPROJ - // generator will instead of binding the commands with " && " will insert a proper newline into - // the VCPROJ file. We sometimes use this method of splitting commands if the custom buildstep - // contains a command-line which is too big to run on certain OS. - QString cmds; - int end = tool.CommandLine.count(); - for(int i = 0; i < end; ++i) { - QString cmdl = tool.CommandLine.at(i); - if (cmdl.contains("\r\t")) { - if (i == end - 1) - cmdl = cmdl.trimmed(); - cmdl.replace("\r\t", " && "); - } else if (cmdl.contains("\r\n")) { - ; - } else if (cmdl.contains("\r\\h")) { - // The above \r\n should work, but doesn't, so we have this hack - cmdl.replace("\r\\h", "\r\n"); - } else { - if (i < end - 1) - cmdl += " && "; - } - cmds += cmdl; - } return xml << tag(_Tool) << attrS(_Name, tool.ToolName) << attrX(_AdditionalDependencies, tool.AdditionalDependencies, ";") - << attrS(_CommandLine, cmds) + << attrS(_CommandLine, tool.CommandLine.join(vcCommandSeparator())) << attrS(_Description, tool.Description) << attrX(_Outputs, tool.Outputs, ";") << attrS(_Path, tool.ToolPath) @@ -2002,7 +1995,7 @@ XmlOutput &operator<<(XmlOutput &xml, const VCEventTool &tool) << tag(_Tool) << attrS(_Name, tool.ToolName) << attrS(_Path, tool.ToolPath) - << attrS(_CommandLine, tool.CommandLine) + << attrS(_CommandLine, tool.CommandLine.join(vcCommandSeparator())) << attrS(_Description, tool.Description) << attrT(_ExcludedFromBuild, tool.ExcludedFromBuild) << closetag(_Tool); @@ -2296,7 +2289,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) if (!CustomBuildTool.Description.isEmpty()) CustomBuildTool.Description += " & "; CustomBuildTool.Description += cmd_name; - CustomBuildTool.CommandLine += cmd.trimmed().split("\n", QString::SkipEmptyParts); + CustomBuildTool.CommandLine += VCToolBase::fixCommandLine(cmd.trimmed()); int space = cmd.indexOf(' '); QFileInfo finf(cmd.left(space)); if (CustomBuildTool.ToolPath.isEmpty()) |