Cosmos/source2/Build/Cosmos.Build.MSBuild/NAsm.cs
mterwoord_cp f0822e6123
2010-08-11 12:00:40 +00:00

97 lines
No EOL
2.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Build.Utilities;
using Microsoft.Build.Framework;
using System.IO;
using System.Diagnostics;
namespace Cosmos.Build.MSBuild
{
public class NAsm : BaseToolTask
{
#region Property
[Required]
public string InputFile
{
get;
set;
}
[Required]
public string OutputFile
{
get;
set;
}
public bool IsELF
{
get;
set;
}
[Required]
public string ExePath
{
get;
set;
}
#endregion
public override bool Execute()
{
if (File.Exists(OutputFile))
{
File.Delete(OutputFile);
}
if (!File.Exists(InputFile))
{
Log.LogError("Input file does not exist!");
return false;
}
if (!File.Exists(ExePath))
{
Log.LogError("Exe file not found! (File = '" + ExePath + "')");
return false;
}
var xFormat = "bin";
if (IsELF)
{
xFormat = "elf";
}
var xResult = ExecuteTool(
Path.GetDirectoryName(OutputFile),
ExePath,
String.Format("-g -f {0} -o \"{1}\" -D{3}_COMPILATION \"{2}\"", xFormat, Path.Combine(Environment.CurrentDirectory, OutputFile), Path.Combine(Environment.CurrentDirectory, InputFile), xFormat.ToUpper()),
"NAsm");
if (xResult)
{
Log.LogMessage("{0} -> {1}", InputFile, OutputFile);
}
return xResult;
}
//public void Execute()
//{
// Init();
// buildFileUtils.RemoveFile(BuildPath + "output.obj");
// var xFormat = "bin";
// if (IsELF)
// {
// xFormat = "elf";
// }
// Global.Call(ToolsPath + @"nasm\nasm.exe", String.Format("-g -f {0} -o \"{1}\" \"{2}\"", xFormat, BuildPath + "output.obj", AsmPath + "main.asm"), BuildPath);
// Finish();
//}
}
}