From 01fc2eeafe99bfc86b72639c10b4bc7b614f7c2d Mon Sep 17 00:00:00 2001 From: Trivalik_cp <42497cfff885d3ca0e6fda54fb6262dd42101bd5sx56jUzf> Date: Fri, 3 Jun 2011 21:41:37 +0000 Subject: [PATCH] add view of nasm warnings --- .../Cosmos.Build.MSBuild/BaseToolTask.cs | 66 +++++++++++++++---- source2/Build/Cosmos.Build.MSBuild/NAsm.cs | 13 +++- 2 files changed, 63 insertions(+), 16 deletions(-) diff --git a/source2/Build/Cosmos.Build.MSBuild/BaseToolTask.cs b/source2/Build/Cosmos.Build.MSBuild/BaseToolTask.cs index 2a53bc659..14bc98c6e 100644 --- a/source2/Build/Cosmos.Build.MSBuild/BaseToolTask.cs +++ b/source2/Build/Cosmos.Build.MSBuild/BaseToolTask.cs @@ -7,6 +7,13 @@ using System.Diagnostics; namespace Cosmos.Build.MSBuild { + public enum WriteType + { + Warning, + Error, + Info + } + public abstract class BaseToolTask : AppDomainIsolatedTask { protected bool ExecuteTool(string workingDir, string filename, string arguments, string name) @@ -49,21 +56,24 @@ namespace Cosmos.Build.MSBuild { Log.LogError("Error occurred while invoking {0}.", name); } - foreach (var xError in mErrors) - { - Log.LogError(ExtendLineError(xError)); - } - foreach (var xOutput in mOutput) - { - Log.LogError(xOutput); - } + return false; } - else + WriteType typ; + foreach (var xError in mErrors) { - foreach (var xOutput in mOutput) + string error = xError; + if(ExtendLineError(xProcess.ExitCode, ref error, out typ)) { - Log.LogMessage(xOutput); + Logs(typ, error); + } + } + foreach (var xOutput in mOutput) + { + string output = xOutput; + if (ExtendLineError(xProcess.ExitCode, ref output, out typ)) + { + Logs(typ, output); } } } @@ -73,9 +83,39 @@ namespace Cosmos.Build.MSBuild private List mErrors; private List mOutput; - public virtual string ExtendLineError(string errorMessage) + public virtual bool ExtendLineError(int exitCode, ref string errorMessage, out WriteType typ) { - return errorMessage; + typ = WriteType.Error; + if (exitCode == 0) + return false; + return true; + } + + public virtual bool ExtendLineOutput(int exitCode, ref string errorMessage, out WriteType typ) + { + typ = WriteType.Info; + return true; + } + + public void Logs(WriteType typ, string message) + { + //TODO remove + Log.LogCommandLine(message); + switch (typ) + { + case WriteType.Warning: + Log.LogWarning(message); + break; + case WriteType.Error: + Log.LogError(message); + break; + case WriteType.Info: + Log.LogMessage(message); + break; + default: + Log.LogError(message); + break; + } } } } \ No newline at end of file diff --git a/source2/Build/Cosmos.Build.MSBuild/NAsm.cs b/source2/Build/Cosmos.Build.MSBuild/NAsm.cs index 503666127..6037cb1c2 100644 --- a/source2/Build/Cosmos.Build.MSBuild/NAsm.cs +++ b/source2/Build/Cosmos.Build.MSBuild/NAsm.cs @@ -75,21 +75,28 @@ namespace Cosmos.Build.MSBuild return xResult; } - public override string ExtendLineError(string errorMessage) + public override bool ExtendLineError(int exitCode, ref string errorMessage, out WriteType typ) { + typ = WriteType.Error; try { if (errorMessage.StartsWith(InputFile)) { + int IndexFile = errorMessage.LastIndexOf('\\', InputFile.Length); + string file = errorMessage.Substring(IndexFile + 1, InputFile.Length - IndexFile - 1); string[] split = errorMessage.Substring(InputFile.Length).Split(':'); + if(split.Length > 3 && split[2].Contains("warning")) + typ = WriteType.Warning; uint lineNumber = uint.Parse(split[1]); - return errorMessage + " Code: " + GetLine(InputFile, lineNumber); + errorMessage = file + " Line: " + lineNumber + " Code: " + GetLine(InputFile, lineNumber).Trim(); + this.BuildEngine.LogMessageEvent(new BuildMessageEventArgs(errorMessage,"","",MessageImportance.High)); + } } catch (Exception) { } - return base.ExtendLineError(errorMessage); + return true; } private static string GetLine(string fileName, uint line)