From 49b39288133272578b8be86e3ced4468927fce5b Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sun, 12 May 2024 11:43:32 +0200 Subject: Cleanup build --- .gitignore | 3 +-- build.bat | 19 ++++++++++++++++--- emulator/hart_test.c | 2 -- emulator/lib.c | 3 +++ emulator/main.c | 4 ---- 5 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 emulator/lib.c diff --git a/.gitignore b/.gitignore index 871d882..fcb6a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -*.exe -*.bin +build diff --git a/build.bat b/build.bat index c9da4e4..d7c7ea7 100644 --- a/build.bat +++ b/build.bat @@ -1,5 +1,18 @@ -clang emulator/main.c -o emulator.exe -std=c11 -D_CRT_SECURE_NO_WARNINGS -I. -clang emulator/hart_test.c -o hart_test.exe -std=c11 -D_CRT_SECURE_NO_WARNINGS -I. +@echo off -clang --target=riscv32 -march=rv32i -e _main -nostdlib main.asm -o main.bin +SET BUILD_OPTS= -std=c11 -D_CRT_SECURE_NO_WARNINGS -I. + +IF NOT EXIST build mkdir build + +echo emulator.lib +clang emulator/lib.c -o build/emulator.lib %BUILD_OPTS% -fuse-ld=llvm-lib + +echo emulator.exe +clang emulator/main.c build/emulator.lib -o build/emulator.exe %BUILD_OPTS% + +echo hart_test.exe +clang emulator/hart_test.c build/emulator.lib -o build/hart_test.exe %BUILD_OPTS% + +echo main.bin +clang --target=riscv32 -march=rv32i -e _main -nostdlib main.asm -o build/main.bin diff --git a/emulator/hart_test.c b/emulator/hart_test.c index 5509dab..5f2549b 100644 --- a/emulator/hart_test.c +++ b/emulator/hart_test.c @@ -247,5 +247,3 @@ int main(int argc, char* argv[]) test(); return EXIT_SUCCESS; } - -#include "emulator/hart.c" diff --git a/emulator/lib.c b/emulator/lib.c new file mode 100644 index 0000000..453a3f9 --- /dev/null +++ b/emulator/lib.c @@ -0,0 +1,3 @@ +#include "hart.c" +#include "elf.c" + diff --git a/emulator/main.c b/emulator/main.c index a00a717..4bf99a3 100644 --- a/emulator/main.c +++ b/emulator/main.c @@ -31,7 +31,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - -#include "emulator/hart.c" -#include "emulator/elf.c" - -- cgit