mirror of
https://github.com/danbulant/Cosmos
synced 2026-06-05 15:51:56 +00:00
add view of nasm warnings
This commit is contained in:
parent
83747e6df9
commit
01fc2eeafe
2 changed files with 63 additions and 16 deletions
|
|
@ -7,6 +7,13 @@ using System.Diagnostics;
|
||||||
|
|
||||||
namespace Cosmos.Build.MSBuild
|
namespace Cosmos.Build.MSBuild
|
||||||
{
|
{
|
||||||
|
public enum WriteType
|
||||||
|
{
|
||||||
|
Warning,
|
||||||
|
Error,
|
||||||
|
Info
|
||||||
|
}
|
||||||
|
|
||||||
public abstract class BaseToolTask : AppDomainIsolatedTask
|
public abstract class BaseToolTask : AppDomainIsolatedTask
|
||||||
{
|
{
|
||||||
protected bool ExecuteTool(string workingDir, string filename, string arguments, string name)
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
WriteType typ;
|
||||||
|
foreach (var xError in mErrors)
|
||||||
{
|
{
|
||||||
|
string error = xError;
|
||||||
|
if(ExtendLineError(xProcess.ExitCode, ref error, out typ))
|
||||||
|
{
|
||||||
|
Logs(typ, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach (var xOutput in mOutput)
|
foreach (var xOutput in mOutput)
|
||||||
{
|
{
|
||||||
Log.LogMessage(xOutput);
|
string output = xOutput;
|
||||||
|
if (ExtendLineError(xProcess.ExitCode, ref output, out typ))
|
||||||
|
{
|
||||||
|
Logs(typ, output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,9 +83,39 @@ namespace Cosmos.Build.MSBuild
|
||||||
private List<string> mErrors;
|
private List<string> mErrors;
|
||||||
private List<string> mOutput;
|
private List<string> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -75,21 +75,28 @@ namespace Cosmos.Build.MSBuild
|
||||||
return xResult;
|
return xResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ExtendLineError(string errorMessage)
|
public override bool ExtendLineError(int exitCode, ref string errorMessage, out WriteType typ)
|
||||||
{
|
{
|
||||||
|
typ = WriteType.Error;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (errorMessage.StartsWith(InputFile))
|
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(':');
|
string[] split = errorMessage.Substring(InputFile.Length).Split(':');
|
||||||
|
if(split.Length > 3 && split[2].Contains("warning"))
|
||||||
|
typ = WriteType.Warning;
|
||||||
uint lineNumber = uint.Parse(split[1]);
|
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)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
return base.ExtendLineError(errorMessage);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetLine(string fileName, uint line)
|
private static string GetLine(string fileName, uint line)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue