Add TS code embedding
This commit is contained in:
@@ -3,7 +3,12 @@
|
|||||||
import { script, step, cmd, $ } from "sailet";
|
import { script, step, cmd, $ } from "sailet";
|
||||||
|
|
||||||
script("build", () => [
|
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`)]),
|
step("Build ISO", () => [cmd($`./src/scripts/build_iso.sh`)]),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "quickjs.h"
|
#include "quickjs.h"
|
||||||
#include "efi.h"
|
#include "efi.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "system_prog.h"
|
||||||
|
|
||||||
static EFI_SYSTEM_TABLE *gST = NULL;
|
static EFI_SYSTEM_TABLE *gST = NULL;
|
||||||
|
|
||||||
@@ -127,10 +128,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
|
|||||||
|
|
||||||
initKC(ctx);
|
initKC(ctx);
|
||||||
|
|
||||||
const char *code =
|
JSValue val = JS_Eval(ctx, SYSTEM_PROG_JS, strlen(SYSTEM_PROG_JS), "<input>", JS_EVAL_TYPE_GLOBAL);
|
||||||
"kc.println(\"Hello from Kernel C!\")";
|
|
||||||
|
|
||||||
JSValue val = JS_Eval(ctx, code, strlen(code), "<input>", JS_EVAL_TYPE_GLOBAL);
|
|
||||||
|
|
||||||
if (JS_IsException(val)) {
|
if (JS_IsException(val)) {
|
||||||
JSValue ex = JS_GetException(ctx);
|
JSValue ex = JS_GetException(ctx);
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
rm -rf out
|
|
||||||
|
|
||||||
mkdir -p out
|
mkdir -p out
|
||||||
mkdir -p out/core
|
mkdir -p out/core
|
||||||
mkdir -p out/lib
|
mkdir -p out/lib
|
||||||
@@ -122,6 +120,7 @@ clang -target x86_64-pc-win32-coff \
|
|||||||
-mno-red-zone \
|
-mno-red-zone \
|
||||||
-Isrc/core/compat \
|
-Isrc/core/compat \
|
||||||
-Isrc/lib/quickjs \
|
-Isrc/lib/quickjs \
|
||||||
|
-Iout/system \
|
||||||
-D_GNU_SOURCE \
|
-D_GNU_SOURCE \
|
||||||
-DUEFI \
|
-DUEFI \
|
||||||
-DCONFIG_VERSION=\"2021-03-27\" \
|
-DCONFIG_VERSION=\"2021-03-27\" \
|
||||||
|
|||||||
7
src/scripts/build_system.sh
Executable file
7
src/scripts/build_system.sh
Executable file
@@ -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
|
||||||
12
src/scripts/embed_system.sh
Executable file
12
src/scripts/embed_system.sh
Executable file
@@ -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
|
||||||
5
src/scripts/prepare_build.sh
Executable file
5
src/scripts/prepare_build.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
rm -rf out
|
||||||
|
|
||||||
@@ -1 +1 @@
|
|||||||
kc.println("Hello via Bun!");
|
kc.println("Kernel works!");
|
||||||
|
|||||||
Reference in New Issue
Block a user