mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-19 12:30:32 +00:00
73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using Microsoft.Build.Framework;
|
|
using Microsoft.Build.Utilities;
|
|
|
|
using IL2CPU.Debug.Symbols;
|
|
|
|
namespace Cosmos.Build.Tasks
|
|
{
|
|
public class ExtractMapFromElfFile : ToolTask
|
|
{
|
|
[Required]
|
|
public string InputFile { get; set; }
|
|
|
|
[Required]
|
|
public string MapFile { get; set; }
|
|
|
|
[Required]
|
|
public string DebugInfoFile { get; set; }
|
|
|
|
protected override string ToolName => "objdump.exe";
|
|
|
|
protected override bool ValidateParameters()
|
|
{
|
|
if (!File.Exists(InputFile))
|
|
{
|
|
Log.LogError(nameof(InputFile) + " doesn't exist!");
|
|
}
|
|
|
|
return !Log.HasLoggedErrors;
|
|
}
|
|
|
|
protected override string GenerateFullPathToTool()
|
|
{
|
|
if (String.IsNullOrWhiteSpace(ToolExe))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (String.IsNullOrWhiteSpace(ToolPath))
|
|
{
|
|
return Path.Combine(Directory.GetCurrentDirectory(), ToolExe);
|
|
}
|
|
|
|
return Path.Combine(Path.GetFullPath(ToolPath), ToolExe);
|
|
}
|
|
|
|
protected override string GenerateCommandLineCommands()
|
|
{
|
|
var xBuilder = new CommandLineBuilder();
|
|
|
|
xBuilder.AppendSwitch("--wide");
|
|
xBuilder.AppendSwitch("--syms");
|
|
|
|
xBuilder.AppendSwitch(">");
|
|
xBuilder.AppendFileNameIfNotNull(MapFile);
|
|
|
|
return xBuilder.ToString();
|
|
}
|
|
|
|
public override bool Execute()
|
|
{
|
|
if (!base.Execute())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ObjDump.ExtractMapSymbolsForElfFile(DebugInfoFile, MapFile);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|