diff --git a/sailet.config.ts b/sailet.config.ts
index 1534893..09e1086 100644
--- a/sailet.config.ts
+++ b/sailet.config.ts
@@ -3,7 +3,12 @@
import { script, step, cmd, $ } from "sailet";
script("build", () => [
- step("Build core", () => [cmd($`./src/scripts/build_core.sh`)]),
+ step("Prepare", () => [cmd($`./src/scripts/prepare_build.sh`)]),
+ step("Build EFI", () => [
+ cmd($`./src/scripts/build_system.sh`),
+ cmd($`./src/scripts/embed_system.sh`),
+ cmd($`./src/scripts/build_core.sh`),
+ ]),
step("Build ISO", () => [cmd($`./src/scripts/build_iso.sh`)]),
]);
diff --git a/src/core/main.c b/src/core/main.c
index c9ebe8c..0d0e3ea 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -6,6 +6,7 @@
#include "quickjs.h"
#include "efi.h"
#include "util.h"
+#include "system_prog.h"
static EFI_SYSTEM_TABLE *gST = NULL;
@@ -127,10 +128,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
initKC(ctx);
- const char *code =
- "kc.println(\"Hello from Kernel C!\")";
-
- JSValue val = JS_Eval(ctx, code, strlen(code), "", JS_EVAL_TYPE_GLOBAL);
+ JSValue val = JS_Eval(ctx, SYSTEM_PROG_JS, strlen(SYSTEM_PROG_JS), "", JS_EVAL_TYPE_GLOBAL);
if (JS_IsException(val)) {
JSValue ex = JS_GetException(ctx);
diff --git a/src/scripts/build_core.sh b/src/scripts/build_core.sh
index 0a375c3..9d429d4 100755
--- a/src/scripts/build_core.sh
+++ b/src/scripts/build_core.sh
@@ -1,8 +1,6 @@
#!/bin/bash
set -e
-rm -rf out
-
mkdir -p out
mkdir -p out/core
mkdir -p out/lib
@@ -122,6 +120,7 @@ clang -target x86_64-pc-win32-coff \
-mno-red-zone \
-Isrc/core/compat \
-Isrc/lib/quickjs \
+ -Iout/system \
-D_GNU_SOURCE \
-DUEFI \
-DCONFIG_VERSION=\"2021-03-27\" \
diff --git a/src/scripts/build_system.sh b/src/scripts/build_system.sh
new file mode 100755
index 0000000..6d758bc
--- /dev/null
+++ b/src/scripts/build_system.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+set -e
+
+mkdir -p out
+mkdir -p out/system
+
+bun build --outdir out/system src/system/src/index.ts
\ No newline at end of file
diff --git a/src/scripts/embed_system.sh b/src/scripts/embed_system.sh
new file mode 100755
index 0000000..5da5622
--- /dev/null
+++ b/src/scripts/embed_system.sh
@@ -0,0 +1,12 @@
+#!/bin/bash
+set -e
+
+echo "#ifndef SYSTEM_PROG_H" > out/system/system_prog.h
+echo "#define SYSTEM_PROG_H" >> out/system/system_prog.h
+echo "const char* SYSTEM_PROG_JS = \\" >> out/system/system_prog.h
+while IFS= read -r line; do
+ ESCAPED_LINE=$(echo "$line" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g')
+ echo "\"${ESCAPED_LINE}\\n\"" >> out/system/system_prog.h
+done < out/system/index.js
+echo ";" >> out/system/system_prog.h
+echo "#endif" >> out/system/system_prog.h
\ No newline at end of file
diff --git a/src/scripts/prepare_build.sh b/src/scripts/prepare_build.sh
new file mode 100755
index 0000000..6f7c2ed
--- /dev/null
+++ b/src/scripts/prepare_build.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+set -e
+
+rm -rf out
+
diff --git a/src/system/src/index.ts b/src/system/src/index.ts
index b433fb7..df2480f 100644
--- a/src/system/src/index.ts
+++ b/src/system/src/index.ts
@@ -1 +1 @@
-kc.println("Hello via Bun!");
+kc.println("Kernel works!");