From f65cfadd041078b80389c178d4f8be055163bdae Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Aug 2019 10:52:52 +0200 Subject: Improve readability of commands in VS project files The commands are separated by "if errorlevel 1 goto VCEnd" lines to make sure we abort on the first failure. However, we also insert magic comments starting with "Rem" for IncrediBuild. These do not need error checking. Also, the last command does not need error checking. The XML line ending entities are also unneeded. By using proper line endings we ensure that commands appear on separate lines in Visual Studio's property editor. Change-Id: Ifbf7525281e892c820034fafc64b555fff3dc756 Reviewed-by: Miguel Costa --- qmake/generators/win32/msbuild_objectmodel.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'qmake/generators/win32/msbuild_objectmodel.cpp') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 3116238aa0..0515c7404f 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -300,14 +300,17 @@ inline XmlOutput::xml_output valueTagT( const triState v) return valueTag(v == _True ? "true" : "false"); } -static QString vcxCommandSeparator() +static QString commandLinesForOutput(QStringList commands) { // MSBuild puts the contents of the custom commands into a batch file and calls 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 VCEnd "); - return cmdSep; + static QString errchk = QStringLiteral("if errorlevel 1 goto VCEnd"); + for (int i = commands.count() - 2; i >= 0; --i) { + if (!commands.at(i).startsWith("rem", Qt::CaseInsensitive)) + commands.insert(i + 1, errchk); + } + return commands.join('\n'); } static QString unquote(const QString &value) @@ -1658,7 +1661,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCCustomBuildTool &tool) { xml << tag("Command") << attrTag("Condition", condition) - << valueTag(tool.CommandLine.join(vcxCommandSeparator())); + << valueTag(commandLinesForOutput(tool.CommandLine)); } if ( !tool.Description.isEmpty() ) @@ -1712,7 +1715,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCEventTool &tool) { xml << tag(tool.EventName) - << tag(_Command) << valueTag(tool.CommandLine.join(vcxCommandSeparator())) + << tag(_Command) << valueTag(commandLinesForOutput(tool.CommandLine)) << tag(_Message) << valueTag(tool.Description) << closetag(tool.EventName); } -- cgit v1.2.3