diff --git a/src/compiler/CLI/CLI.csproj b/src/compiler/CLI/CLI.csproj
index 02350ff..fec4a24 100644
--- a/src/compiler/CLI/CLI.csproj
+++ b/src/compiler/CLI/CLI.csproj
@@ -14,4 +14,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/compiler/CLI/Program.cs b/src/compiler/CLI/Program.cs
index ae71806..e59d992 100644
--- a/src/compiler/CLI/Program.cs
+++ b/src/compiler/CLI/Program.cs
@@ -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();
-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
+var objectFiles = new List();
+
+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)
{
diff --git a/src/compiler/CLI/runtime/libruntime_x64.a b/src/compiler/CLI/runtime/libruntime_x64.a
new file mode 100644
index 0000000..607bb70
Binary files /dev/null and b/src/compiler/CLI/runtime/libruntime_x64.a differ