This commit is contained in:
2026-02-08 00:05:59 +01:00
parent 3b75e62aa7
commit cb2411a7eb
11 changed files with 1042 additions and 806 deletions

View File

@@ -1,7 +1,5 @@
using System.Diagnostics;
using NubLang.Ast;
using NubLang.Ast;
using NubLang.Diagnostics;
using NubLang.Generation;
using NubLang.Syntax;
var diagnostics = new List<Diagnostic>();
@@ -42,50 +40,4 @@ if (diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Erro
return 1;
}
var cPaths = new List<string>();
Directory.CreateDirectory(".build");
for (var i = 0; i < args.Length; i++)
{
var file = args[i];
var compilationUnit = compilationUnits[i];
var generator = new Generator(compilationUnit);
var directory = Path.GetDirectoryName(file);
if (!string.IsNullOrWhiteSpace(directory))
{
Directory.CreateDirectory(Path.Combine(".build", directory));
}
var path = Path.Combine(".build", Path.ChangeExtension(file, "c"));
File.WriteAllText(path, generator.Emit());
cPaths.Add(path);
}
var objectPaths = new List<string>();
foreach (var cPath in cPaths)
{
var objectPath = Path.ChangeExtension(cPath, "o");
using var compileProcess = Process.Start("clang", [
"-ffreestanding", "-std=c23",
"-g", "-c",
"-o", objectPath,
cPath,
]);
compileProcess.WaitForExit();
if (compileProcess.ExitCode != 0)
{
Console.Error.WriteLine($"clang failed with exit code {compileProcess.ExitCode}");
return 1;
}
objectPaths.Add(objectPath);
}
Console.Out.WriteLine(string.Join(' ', objectPaths));
return 0;