split compilation into wasm.just + add targets for interpreted wasm

This commit is contained in:
2026-03-12 21:13:06 +01:00
parent 28d1db3b79
commit 0f847d7d2d
3 changed files with 323 additions and 276 deletions

View File

@ -1,5 +1,5 @@
[doc("Trace a golden run using FAIL*")]
[group("fail")]
[group("4: fail")]
trace module:
{{ BOCHS_RUNNER }} \
-V {{ FAIL_SHARE }}/vgabios.bin \
@ -23,7 +23,7 @@ trace module:
# {{ FAIL_DUMP }} {{ BUILD_DIR }}-{{ module }}/trace.pb
[doc("Import a FAIL* golden run trace")]
[group("fail")]
[group("4: fail")]
import module:
{{ FAIL_IMPORT }} --database-option-file ./db.conf -t {{ BUILD_DIR }}-{{ module }}/trace.pb \
-i MemoryImporter \
@ -59,7 +59,7 @@ import module:
@echo "Next step: \"just server {{ module }}\""
[doc("Start the FAIL* campaign server")]
[group("fail")]
[group("4: fail")]
server module:
{{ FAIL_SERVER }} \
--port {{FAIL_SERVER_PORT}} \
@ -72,12 +72,12 @@ server module:
@echo "Next step: \"just client {{ module }}\""
[doc("Stop the FAIL* campaign server")]
[group("fail")]
[group("4: fail")]
stop-server:
pkill -f {{ FAIL_SERVER }}
[doc("Start a FAIL* campaign client")]
[group("fail")]
[group("4: fail")]
client module:
{{ BOCHS_RUNNER }} \
-V {{ FAIL_SHARE }}/vgabios.bin \
@ -97,7 +97,7 @@ client module:
@echo "Next step: \"just result {{ module }}\" or \"just resultbrowser\""
[doc("Query FAIL* marker statistics from the database")]
[group("fail")]
[group("4: fail")]
result module:
@echo "select variant, benchmark, resulttype, sum(t.time2 - t.time1 + 1) as faults \
FROM variant v \
@ -110,6 +110,6 @@ result module:
ORDER BY variant, benchmark, resulttype;" | mariadb --defaults-file=./db.conf -t
[doc("Start the FAIL* resultbrowser")]
[group("fail")]
[group("4: fail")]
resultbrowser:
{{ RESULT_BROWSER }} -c ./db.conf --host=0.0.0.0 --port={{RESULTBROWSER_PORT}}

View File

@ -1,3 +1,4 @@
import "wasm.just"
import "fail.just"
BUILD_DIR := "build"
@ -34,7 +35,7 @@ RESULT_BROWSER := "resultbrowser.py"
[default]
[private]
list:
@just --list --unsorted
@just --list
[private]
create-build-dir module:
@ -44,262 +45,12 @@ create-build-dir module:
clean module:
rm -rf {{ BUILD_DIR }}-{{ module }}
# =================================================================================================================== #
# Build WASM module recipes
# =================================================================================================================== #
WASI_CC := f"{{WASI_ROOT}}/bin/clang"
WASI_CFLAGS := "\
--target=wasm32 \
--sysroot={{WASI_ROOT}}/share/wasi-sysroot \
-z stack-size=4096 \
-O0 \
-nostdlib \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--no-gc-sections \
-Wl,--initial-memory=65536 \
-Wl,--export=__heap_base \
-Wl,--export=__data_end \
"
WAMRC := "wamrc"
WAMRCFLAGS := "\
--target=i386 \
--cpu=generic \
--opt-level=0 \
"
XXD := "xxd"
[doc("C -> WASM: Compile a C function to a WASM module using WASI-SDK")]
[group("build-module")]
build-wasm-module module: (create-build-dir module)
{{ WASI_CC }} {{ WASI_CFLAGS }} targets/wasm-module/{{ module }}.c -o {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("WASM -> AOT: Compile a WASM module ahead-of-time using WAMR")]
[group("build-module")]
build-wasm-aot module: (build-wasm-module module)
{{ WAMRC }} {{ WAMRCFLAGS }} -o {{ BUILD_DIR }}-{{ module }}/wasm_module.aot {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("AOT -> C-Array: Dump a WASM module compiled ahead-of-time to a binary array")]
[group("build-module")]
build-wasm-aot-array module: (build-wasm-aot module)
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.aot > {{ BUILD_DIR }}-{{ module }}/wasm_module_array.c
# =================================================================================================================== #
# Host program recipes
# =================================================================================================================== #
# FAIL*
CROSS_CFLAGS := "\
-I./targets/wasm-host \
-O2 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ffreestanding \
-fomit-frame-pointer \
-ggdb \
"
CROSS_LDFLAGS := f"\
-Wl,--build-id=none \
-static \
-nostdlib \
-m32 \
-L{{LIBIWASM_RELEASE}} \
-liwasm \
-lc \
-lgcc \
-lm \
"
CROSS_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/baremetal \
"
# LINUX-POSIX
LINUX_CFLAGS := "\
-I./targets/wasm-host \
-O0 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ggdb \
"
LINUX_LDFLAGS := f"\
-Wl,--build-id=none \
-m32 \
-Wl,-rpath,{{LIBIWASM_LINUX_DEBUG}} \
-L{{LIBIWASM_LINUX_DEBUG}} \
-liwasm \
-lm \
"
LINUX_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/linux \
"
# LINUX-Baremetal
LINUX_BAREMETAL_CFLAGS := "\
-I./targets/wasm-host \
-O0 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ffreestanding \
-ggdb \
"
LINUX_BAREMETAL_LDFLAGS := f"\
-Wl,--build-id=none \
-static \
-nostdlib \
-m32 \
-L{{LIBIWASM_DEBUG}} \
-liwasm \
-lc \
-lgcc \
-lm \
--entry main \
"
LINUX_BAREMETAL_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/baremetal \
"
[private]
build-wasm-host-fail module:
{{ CROSS_CC }} {{ CROSS_CFLAGS }} {{ CROSS_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-linux module:
{{ LINUX_CC }} {{ LINUX_CFLAGS }} {{ LINUX_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-linux-baremetal module:
{{ CROSS_CC }} {{ LINUX_BAREMETAL_CFLAGS }} {{ LINUX_BAREMETAL_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-dispatch module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just build-wasm-host-fail "{{ module }}"
elif [ "{{ target }}" = "linux" ]; then
just build-wasm-host-linux "{{ module }}"
elif [ "{{ target }}" = "linux-baremetal" ]; then
just build-wasm-host-linux-baremetal "{{ module }}"
else
echo "unknown target: {{ target }}" >&2
exit 1
fi
[doc("Compile C-Host: The host uses WAMR to load the AOT module")]
[group("build-host")]
build-wasm-host module target="fail": (build-wasm-aot-array module) && (build-wasm-host-dispatch module target)
cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c
sed -i \
-e "s/__WASM_ARRAY_FILE__/wasm_module_array.c/g" \
-e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_aot/g" \
-e "s/__WASM_ARRAY_LEN__/build_{{ module }}_wasm_module_aot_len/g" \
{{ BUILD_DIR }}-{{ module }}/module_host.c
[private]
build-system-startup-fail module:
{{ CROSS_CC }} targets/startup.s {{ CROSS_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/startup.o
[doc("Compile bootloader")]
[group("build-host")]
build-system-startup module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just build-system-startup-fail "{{ module }}"
else
echo "{{ target }} doesn't need bootloader"
fi
[private]
build-system-syscalls-fail module:
{{ CROSS_CC }} targets/syscalls.c {{ CROSS_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/syscalls.o
[private]
build-system-syscalls-linux-baremetal module:
{{ CROSS_CC }} targets/syscalls.c {{ LINUX_BAREMETAL_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/syscalls.o
[doc("Compile newlib syscall stubs")]
[group("build-host")]
build-system-syscalls module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just build-system-syscalls-fail "{{ module }}"
elif [ "{{ target }}" = "linux-baremetal" ]; then
just build-system-syscalls-linux-baremetal "{{ module }}"
else
echo "{{ target }} doesn't require syscall stubs"
fi
[private]
link-system-fail module:
{{ CROSS_CC }} \
-Wl,-T targets/linker.ld \
{{ BUILD_DIR }}-{{ module }}/system.o \
{{ BUILD_DIR }}-{{ module }}/startup.o \
{{ BUILD_DIR }}-{{ module }}/syscalls.o \
{{ CROSS_LDFLAGS }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[private]
link-system-linux module:
{{ LINUX_CC }} \
{{ BUILD_DIR }}-{{ module }}/system.o \
{{ LINUX_LDFLAGS }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[private]
link-system-linux-baremetal module:
{{ CROSS_CC }} \
{{ BUILD_DIR }}-{{ module }}/system.o \
{{ BUILD_DIR }}-{{ module }}/syscalls.o \
{{ LINUX_BAREMETAL_LDFLAGS }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[doc("Link C-Host, syscall stubs and bootloader")]
[group("build-host")]
link-system module target="fail": (build-wasm-host module target) (build-system-syscalls module target) (build-system-startup module target)
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just link-system-fail "{{ module }}"
elif [ "{{ target }}" = "linux" ]; then
just link-system-linux "{{ module }}"
elif [ "{{ target }}" = "linux-baremetal" ]; then
just link-system-linux-baremetal "{{ module }}"
else
echo "unknown target: {{ target }}" >&2
exit 1
fi
[doc("Create bootdisk")]
[group("build-host")]
build-iso module target="fail": (link-system module target)
mkdir -p {{ BUILD_DIR }}-{{ module }}/grub/boot/grub
cp targets/grub.cfg {{ BUILD_DIR }}-{{ module }}/grub/boot/grub/
cp {{ BUILD_DIR }}-{{ module }}/system.elf {{ BUILD_DIR }}-{{ module }}/grub/boot/
grub-mkrescue -o {{ BUILD_DIR }}-{{ module }}/system.iso {{ BUILD_DIR }}-{{ module }}/grub
# =================================================================================================================== #
# MySQL recipes
# =================================================================================================================== #
[doc("Start MySQL container to receive FAIL* trace/campaign results")]
[group("fail-db")]
[group("3: fail db")]
start-db:
docker run -d \
--name fail-db \
@ -311,17 +62,17 @@ start-db:
mysql
[doc("Connect to MySQL database using DBeaver")]
[group("fail-db")]
[group("3: fail db")]
connect-db:
dbeaver -con "name=fail|driver=mysql|host=localhost|port=3306|database=fail|user=fail|password=fail"
[doc("Stop MySQL container")]
[group("fail-db")]
[group("3: fail db")]
stop-db:
docker stop fail-db
[doc("Remove MySQL container")]
[group("fail-db")]
[group("3: fail db")]
remove-db:
docker container rm fail-db
@ -329,11 +80,6 @@ remove-db:
# Debugging recipes
# =================================================================================================================== #
[doc("Run binary")]
[group("debug")]
run module:
{{ BUILD_DIR }}-{{ module }}/system.elf
[doc("Launch gdb")]
[group("debug")]
gdb module:
@ -345,21 +91,57 @@ radare module:
radare2 -AA -c "s dbg.os_main; pdf" {{ BUILD_DIR }}-{{ module }}/system.elf
# =================================================================================================================== #
# AIO
# Just do it
# =================================================================================================================== #
[group("just do it")]
[private]
build-common-pre module:
just clean {{ module }}
just create-build-dir {{ module }}
just build-wasm-module {{ module }}
[private]
build-common-post module target="fail":
just build-wasm-host {{ module }} {{ target }}
just build-system-startup {{ module }} {{ target }}
just build-system-syscalls {{ module }} {{ target }}
just link-system {{ module }} {{ target }}
just build-iso {{ module }}
[doc("Perform all steps for a fail/linux/linux-bm build with aot/interp WASM")]
[group("5: just do it")]
build module target="fail" mode="aot":
#!/usr/bin/env sh
just build-common-pre {{ module }}
if [ "{{ mode }}" = "aot" ]; then
just build-wasm-aot {{ module }}
just build-wasm-aot-array {{ module }}
just prepare-aot-host {{ module }} {{ target }}
elif [ "{{ mode }}" = "interp" ]; then
just build-wasm-interp-array {{ module }}
just prepare-interp-host {{ module }} {{ target }}
else
echo "unknown mode: {{ mode }}" >&2
exit 1
fi
just build-common-post {{ module }} {{ target }}
[doc("Run binary")]
[group("5: just do it")]
run module:
{{ BUILD_DIR }}-{{ module }}/system.elf
[doc("Send binaries to mars")]
[group("5: just do it")]
upload module:
scp -r {{ BUILD_DIR }}-{{ module }} mars:~/Documents/failnix/{{ BUILD_DIR }}-{{ module }}
[group("just do it")]
build module target="fail": (build-iso module target)
[group("just do it")]
[doc("Perform all steps for a FAIL* campaign")]
[group("5: just do it")]
inject module:
just clean {{ module }}
just build {{ module }} "fail"
just start-db
@echo "Waiting for database..."
sleep 20

265
wasm.just Normal file
View File

@ -0,0 +1,265 @@
# =================================================================================================================== #
# Build WASM module recipes
# =================================================================================================================== #
WASI_CC := f"{{WASI_ROOT}}/bin/clang"
WASI_CFLAGS := "\
--target=wasm32 \
--sysroot={{WASI_ROOT}}/share/wasi-sysroot \
-z stack-size=4096 \
-O0 \
-nostdlib \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--no-gc-sections \
-Wl,--initial-memory=65536 \
-Wl,--export=__heap_base \
-Wl,--export=__data_end \
"
WAMRC := "wamrc"
WAMRCFLAGS := "\
--target=i386 \
--cpu=generic \
--opt-level=0 \
"
XXD := "xxd"
[doc("C -> WASM: Compile a C function to a WASM module using WASI-SDK")]
[group("1: build module")]
build-wasm-module module:
{{ WASI_CC }} {{ WASI_CFLAGS }} targets/wasm-module/{{ module }}.c -o {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("WASM -> AOT: Compile a WASM module ahead-of-time using WAMR")]
[group("1: build module")]
build-wasm-aot module:
{{ WAMRC }} {{ WAMRCFLAGS }} -o {{ BUILD_DIR }}-{{ module }}/wasm_module.aot {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("AOT -> C-Array: Dump a WASM module compiled ahead-of-time to a binary array")]
[group("1: build module")]
build-wasm-aot-array module:
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.aot > {{ BUILD_DIR }}-{{ module }}/wasm_aot_array.c
[doc("WASM -> C-Array: Dump a WASM module to a binary array")]
[group("1: build module")]
build-wasm-interp-array module:
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm > {{ BUILD_DIR }}-{{ module }}/wasm_interp_array.c
# =================================================================================================================== #
# Host program recipes
# =================================================================================================================== #
# FAIL*
CROSS_CFLAGS := "\
-I./targets/wasm-host \
-O2 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ffreestanding \
-fomit-frame-pointer \
-ggdb \
"
CROSS_LDFLAGS := f"\
-Wl,--build-id=none \
-static \
-nostdlib \
-m32 \
-L{{LIBIWASM_RELEASE}} \
-liwasm \
-lc \
-lgcc \
-lm \
"
CROSS_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/baremetal \
"
# LINUX-POSIX
LINUX_CFLAGS := "\
-I./targets/wasm-host \
-O0 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ggdb \
"
LINUX_LDFLAGS := f"\
-Wl,--build-id=none \
-m32 \
-Wl,-rpath,{{LIBIWASM_LINUX_DEBUG}} \
-L{{LIBIWASM_LINUX_DEBUG}} \
-liwasm \
-lm \
"
LINUX_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/linux \
"
# LINUX-Baremetal
LINUX_BAREMETAL_CFLAGS := "\
-I./targets/wasm-host \
-O0 \
-m32 \
-ffunction-sections \
-fdata-sections \
-ffreestanding \
-ggdb \
"
LINUX_BAREMETAL_LDFLAGS := f"\
-Wl,--build-id=none \
-static \
-nostdlib \
-m32 \
-L{{LIBIWASM_DEBUG}} \
-liwasm \
-lc \
-lgcc \
-lm \
--entry main \
"
LINUX_BAREMETAL_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
-I{{WAMR_ROOT}}/core/shared/platform/baremetal \
"
[doc("Insert the AOT array into the host program")]
[group("2: build host")]
prepare-aot-host module target="fail":
cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c
sed -i \
-e "s/__WASM_ARRAY_FILE__/wasm_aot_array.c/g" \
-e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_aot/g" \
-e "s/__WASM_ARRAY_LEN__/build_{{ module }}_wasm_module_aot_len/g" \
{{ BUILD_DIR }}-{{ module }}/module_host.c
[doc("Insert the WASM array into the host program")]
[group("2: build host")]
prepare-interp-host module target="fail":
cp targets/wasm-host/{{ target }}.c {{ BUILD_DIR }}-{{ module }}/module_host.c
sed -i \
-e "s/__WASM_ARRAY_FILE__/wasm_interp_array.c/g" \
-e "s/__WASM_ARRAY__/build_{{ module }}_wasm_module_wasm/g" \
-e "s/__WASM_ARRAY_LEN__/build_{{ module }}_wasm_module_wasm_len/g" \
{{ BUILD_DIR }}-{{ module }}/module_host.c
[private]
build-wasm-host-fail module:
{{ CROSS_CC }} {{ CROSS_CFLAGS }} {{ CROSS_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-linux module:
{{ LINUX_CC }} {{ LINUX_CFLAGS }} {{ LINUX_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[private]
build-wasm-host-linux-baremetal module:
{{ CROSS_CC }} {{ LINUX_BAREMETAL_CFLAGS }} {{ LINUX_BAREMETAL_INCLUDES }} \
-c {{ BUILD_DIR }}-{{ module }}/module_host.c \
-o {{ BUILD_DIR }}-{{ module }}/system.o
[doc("Compile C-Host: The host uses WAMR to load the WASM/AOT module")]
[group("2: build host")]
build-wasm-host module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just build-wasm-host-fail "{{ module }}"
elif [ "{{ target }}" = "linux" ]; then
just build-wasm-host-linux "{{ module }}"
elif [ "{{ target }}" = "linux-baremetal" ]; then
just build-wasm-host-linux-baremetal "{{ module }}"
else
echo "unknown target: {{ target }}" >&2
exit 1
fi
[private]
build-system-startup-fail module:
{{ CROSS_CC }} targets/startup.s {{ CROSS_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/startup.o
[doc("Compile bootloader")]
[group("2: build host")]
build-system-startup module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just build-system-startup-fail "{{ module }}"
else
echo "{{ target }} doesn't need bootloader"
fi
[private]
build-system-syscalls-fail module:
{{ CROSS_CC }} targets/syscalls.c {{ CROSS_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/syscalls.o
[private]
build-system-syscalls-linux-baremetal module:
{{ CROSS_CC }} targets/syscalls.c {{ LINUX_BAREMETAL_CFLAGS }} -c -o {{ BUILD_DIR }}-{{ module }}/syscalls.o
[doc("Compile newlib syscall stubs")]
[group("2: build host")]
build-system-syscalls module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just build-system-syscalls-fail "{{ module }}"
elif [ "{{ target }}" = "linux-baremetal" ]; then
just build-system-syscalls-linux-baremetal "{{ module }}"
else
echo "{{ target }} doesn't require syscall stubs"
fi
[private]
link-system-fail module:
{{ CROSS_CC }} \
-Wl,-T targets/linker.ld \
{{ BUILD_DIR }}-{{ module }}/system.o \
{{ BUILD_DIR }}-{{ module }}/startup.o \
{{ BUILD_DIR }}-{{ module }}/syscalls.o \
{{ CROSS_LDFLAGS }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[private]
link-system-linux module:
{{ LINUX_CC }} \
{{ BUILD_DIR }}-{{ module }}/system.o \
{{ LINUX_LDFLAGS }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[private]
link-system-linux-baremetal module:
{{ CROSS_CC }} \
{{ BUILD_DIR }}-{{ module }}/system.o \
{{ BUILD_DIR }}-{{ module }}/syscalls.o \
{{ LINUX_BAREMETAL_LDFLAGS }} \
-o {{ BUILD_DIR }}-{{ module }}/system.elf
[doc("Link C-Host, syscall stubs and bootloader")]
[group("2: build host")]
link-system module target="fail":
#!/usr/bin/env sh
if [ "{{ target }}" = "fail" ]; then
just link-system-fail "{{ module }}"
elif [ "{{ target }}" = "linux" ]; then
just link-system-linux "{{ module }}"
elif [ "{{ target }}" = "linux-baremetal" ]; then
just link-system-linux-baremetal "{{ module }}"
else
echo "unknown target: {{ target }}" >&2
exit 1
fi
[doc("Create bootdisk")]
[group("2: build host")]
build-iso module:
mkdir -p {{ BUILD_DIR }}-{{ module }}/grub/boot/grub
cp targets/grub.cfg {{ BUILD_DIR }}-{{ module }}/grub/boot/grub/
cp {{ BUILD_DIR }}-{{ module }}/system.elf {{ BUILD_DIR }}-{{ module }}/grub/boot/
grub-mkrescue -o {{ BUILD_DIR }}-{{ module }}/system.iso {{ BUILD_DIR }}-{{ module }}/grub