...
This commit is contained in:
@@ -7,7 +7,7 @@ public static class GCC
|
|||||||
public static async Task<bool> Assemble(string asmPath, string objPath)
|
public static async Task<bool> Assemble(string asmPath, string objPath)
|
||||||
{
|
{
|
||||||
using var gccProcess = new Process();
|
using var gccProcess = new Process();
|
||||||
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-c", asmPath, "-o", objPath])
|
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-nostdlib", "-ffreestanding", "-c", asmPath, "-o", objPath])
|
||||||
{
|
{
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
@@ -30,7 +30,7 @@ public static class GCC
|
|||||||
public static async Task<bool> Link(List<string> objectFiles, string outputPath)
|
public static async Task<bool> Link(List<string> objectFiles, string outputPath)
|
||||||
{
|
{
|
||||||
using var gccProcess = new Process();
|
using var gccProcess = new Process();
|
||||||
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-nostartfiles", "-o", outputPath, ..objectFiles])
|
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-nostdlib", "-ffreestanding", "-o", outputPath, ..objectFiles])
|
||||||
{
|
{
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
|
|||||||
@@ -24,10 +24,31 @@ if (Directory.Exists(BIN_INT_DIR))
|
|||||||
Directory.CreateDirectory(BIN_DIR);
|
Directory.CreateDirectory(BIN_DIR);
|
||||||
Directory.CreateDirectory(BIN_INT_DIR);
|
Directory.CreateDirectory(BIN_INT_DIR);
|
||||||
|
|
||||||
|
var files = new List<string>();
|
||||||
|
|
||||||
|
var compileOnly = false;
|
||||||
|
string? outPath = null;
|
||||||
|
|
||||||
|
foreach (var arg in args)
|
||||||
|
{
|
||||||
|
if (arg == "-c")
|
||||||
|
{
|
||||||
|
compileOnly = true;
|
||||||
|
}
|
||||||
|
else if (arg.StartsWith("-o="))
|
||||||
|
{
|
||||||
|
outPath = arg.Substring("-o=".Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
files.Add(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var diagnostics = new List<Diagnostic>();
|
var diagnostics = new List<Diagnostic>();
|
||||||
var syntaxTrees = new List<SyntaxTree>();
|
var syntaxTrees = new List<SyntaxTree>();
|
||||||
|
|
||||||
foreach (var file in args)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
{
|
{
|
||||||
@@ -36,7 +57,7 @@ foreach (var file in args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var file in args)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
var content = File.ReadAllText(file);
|
var content = File.ReadAllText(file);
|
||||||
var sourceText = new SourceText(file, content);
|
var sourceText = new SourceText(file, content);
|
||||||
@@ -78,9 +99,10 @@ if (diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Erro
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var objectFiles = new List<string>();
|
var objectFiles = new List<string>
|
||||||
|
{
|
||||||
objectFiles.Add("/home/oliste/repos/nub-lang/src/runtime/runtime.o");
|
"libruntime.a"
|
||||||
|
};
|
||||||
|
|
||||||
foreach (var boundSyntaxTree in boundSyntaxTrees)
|
foreach (var boundSyntaxTree in boundSyntaxTrees)
|
||||||
{
|
{
|
||||||
|
|||||||
2
src/runtime/.gitignore
vendored
2
src/runtime/.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
*.o
|
|
||||||
out
|
out
|
||||||
|
out-int
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
CC = gcc
|
CC ?= x86_64-linux-gnu-gcc
|
||||||
|
TARGET ?= x64
|
||||||
|
|
||||||
CFLAGS = -nostdlib -ffreestanding -Wall -Werror -Wextra
|
CFLAGS = -nostdlib -ffreestanding -Wall -Werror -Wextra
|
||||||
|
|
||||||
x64: runtime.o x64.o
|
libruntime: out-int/runtime.o
|
||||||
|
$(CC) $(CFLAGS) -c targets/$(TARGET).s -o out-int/$(TARGET).o
|
||||||
mkdir -p out
|
mkdir -p out
|
||||||
ar rcs out/libruntime.a runtime.o x64.o
|
ar rcs out/libruntime_$(TARGET).a out-int/runtime.o out-int/$(TARGET).o
|
||||||
|
|
||||||
runtime.o: runtime/runtime.c
|
out-int/runtime.o: runtime/runtime.c
|
||||||
$(CC) $(CFLAGS) -c runtime/runtime.c -o runtime.o
|
mkdir -p out-int
|
||||||
|
$(CC) $(CFLAGS) -c runtime/runtime.c -o out-int/runtime.o
|
||||||
x64.o: runtime.o platform/x64.s
|
|
||||||
$(CC) $(CFLAGS) -c platform/x64.s -o x64.o
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -r out runtime.o x64.o
|
rm -r out out-int
|
||||||
|
|||||||
Reference in New Issue
Block a user