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 <miguel.costa@qt.io>
This commit is contained in:
parent
181e5382e7
commit
f65cfadd04
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user