54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System.Diagnostics;
|
|
|
|
namespace NubLang.CLI;
|
|
|
|
public static class GCC
|
|
{
|
|
public static async Task<bool> Assemble(string asmPath, string outPath)
|
|
{
|
|
using var process = new Process();
|
|
process.StartInfo = new ProcessStartInfo("x86_64-elf-as", ["-nostartfiles", "-o", outPath, asmPath])
|
|
{
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
CreateNoWindow = true
|
|
};
|
|
|
|
process.Start();
|
|
|
|
await process.WaitForExitAsync();
|
|
|
|
var errors = await process.StandardError.ReadToEndAsync();
|
|
if (!string.IsNullOrWhiteSpace(errors))
|
|
{
|
|
await Console.Error.WriteLineAsync(errors);
|
|
}
|
|
|
|
return process.ExitCode == 0;
|
|
}
|
|
|
|
public static async Task<bool> Compile(string cPath, string outPath)
|
|
{
|
|
using var process = new Process();
|
|
process.StartInfo = new ProcessStartInfo("gcc", ["-ffreestanding", "-nostartfiles", "-c", "-o", outPath, cPath])
|
|
{
|
|
UseShellExecute = false,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
CreateNoWindow = true
|
|
};
|
|
|
|
process.Start();
|
|
|
|
await process.WaitForExitAsync();
|
|
|
|
var errors = await process.StandardError.ReadToEndAsync();
|
|
if (!string.IsNullOrWhiteSpace(errors))
|
|
{
|
|
await Console.Error.WriteLineAsync(errors);
|
|
}
|
|
|
|
return process.ExitCode == 0;
|
|
}
|
|
} |