This commit is contained in:
nub31
2025-06-26 15:29:59 +02:00
parent 105ac69b1c
commit 082f868572
3 changed files with 31 additions and 11 deletions

View File

@@ -14,4 +14,13 @@
<ProjectReference Include="..\Syntax\Syntax.csproj" /> <ProjectReference Include="..\Syntax\Syntax.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="runtime\" />
</ItemGroup>
<ItemGroup>
<None Remove="runtime\libruntime_x64.a" />
<EmbeddedResource Include="runtime\libruntime_x64.a" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Reflection;
using CLI; using CLI;
using Generation.QBE; using Generation.QBE;
using Syntax; using Syntax;
@@ -26,18 +27,13 @@ Directory.CreateDirectory(BIN_INT_DIR);
var files = new List<string>(); var files = new List<string>();
var compileOnly = false; string? runtimePath = null;
string? outPath = null;
foreach (var arg in args) foreach (var arg in args)
{ {
if (arg == "-c") if (arg.StartsWith("-r="))
{ {
compileOnly = true; runtimePath = arg.Substring("-r=".Length);
}
else if (arg.StartsWith("-o="))
{
outPath = arg.Substring("-o=".Length);
} }
else else
{ {
@@ -99,10 +95,25 @@ if (diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Erro
return 1; return 1;
} }
var objectFiles = new List<string> var objectFiles = new List<string>();
if (runtimePath == null)
{ {
"libruntime.a" const string RUNTIME_NAME = "libruntime_x64";
}; await using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(RUNTIME_NAME);
if (stream == null)
{
throw new Exception("Runtime stream is null");
}
var tmpDir = Directory.CreateTempSubdirectory("nub");
runtimePath = Path.Combine(tmpDir.FullName, RUNTIME_NAME + ".a");
await using var writer = new FileStream(runtimePath, FileMode.Create, FileAccess.Write);
await stream.CopyToAsync(writer);
}
objectFiles.Add(runtimePath);
foreach (var boundSyntaxTree in boundSyntaxTrees) foreach (var boundSyntaxTree in boundSyntaxTrees)
{ {

Binary file not shown.