Fix bugs in cli

This commit is contained in:
nub31
2025-08-18 16:29:41 +02:00
parent 10042de4d7
commit a01539ff24
4 changed files with 53 additions and 47 deletions

View File

@@ -4,19 +4,18 @@ namespace NubLang.CLI;
public static class GCC
{
public static async Task<bool> Assemble(string asm, string objPath)
public static async Task<bool> Assemble(string asmPath, string outPath)
{
var dir = Path.GetDirectoryName(objPath);
var dir = Path.GetDirectoryName(outPath);
if (dir != null)
{
Directory.CreateDirectory(dir);
}
using var process = new Process();
process.StartInfo = new ProcessStartInfo("gcc", ["-xassembler", "-c", "-o", objPath, "-"])
process.StartInfo = new ProcessStartInfo("gcc", ["-xassembler", "-c", "-o", outPath, asmPath])
{
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
@@ -24,9 +23,6 @@ public static class GCC
process.Start();
await process.StandardInput.WriteAsync(asm);
process.StandardInput.Close();
await process.WaitForExitAsync();
var errors = await process.StandardError.ReadToEndAsync();
@@ -50,7 +46,6 @@ public static class GCC
process.StartInfo = new ProcessStartInfo("gcc", ["-nostartfiles", "-o", executablePath, ..objectFiles])
{
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true