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

View File

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

View File

@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Reflection;
using CLI;
using Generation.QBE;
using Syntax;
@@ -26,18 +27,13 @@ Directory.CreateDirectory(BIN_INT_DIR);
var files = new List<string>();
var compileOnly = false;
string? outPath = null;
string? runtimePath = null;
foreach (var arg in args)
{
if (arg == "-c")
if (arg.StartsWith("-r="))
{
compileOnly = true;
}
else if (arg.StartsWith("-o="))
{
outPath = arg.Substring("-o=".Length);
runtimePath = arg.Substring("-r=".Length);
}
else
{
@@ -99,10 +95,25 @@ if (diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Erro
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)
{

Binary file not shown.