diff --git a/.gitignore b/.gitignore index 7c3fd02..11f8f88 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ # Files GEMINI.md +nul +null +esp/NvVars diff --git a/run.sh b/run.sh index 9e1f9f2..96473c2 100644 --- a/run.sh +++ b/run.sh @@ -1,19 +1,44 @@ -#!/bin/bash -set -e +#!/usr/bin/env bash +set -euo pipefail -echo "[build] Compiling kernel..." -cargo build --target x86_64-unknown-uefi +KERNEL_TARGET="x86_64-unknown-uefi" +USERLAND_TARGET="x86_64-unknown-none" +TARGETS=( + "$KERNEL_TARGET" + "$USERLAND_TARGET" +) +EFI_NAME="mana_os.efi" -echo "[build] Setting up ESP..." +if ! command -v rustup >/dev/null 2>&1; then + echo "[ERROR] rustup is required for reproducible target setup!!" + exit 1 +fi + +for TARGET in "${TARGETS[@]}"; do + if ! rustup target list --installed | grep -qx "$TARGET"; then + echo "[SETUP] Installing RUST target: $TARGET" + rustup target add "$TARGET" + fi +done + +echo "[BUILD] Compiling the KERNEL..." +cargo build --target "$KERNEL_TARGET" + +echo "[BUILD] Setting up ESP..." mkdir -p esp/EFI/BOOT -cp target/x86_64-unknown-uefi/debug/mana_os.efi esp/EFI/BOOT/BOOTX64.EFI +cp "target/$KERNEL_TARGET/debug/$EFI_NAME" esp/EFI/BOOT/BOOTX64.EFI if [ ! -f disk.img ]; then - echo "[build] Creating disk.img..." + echo "[BUILD] Creating disk.img..." dd if=/dev/zero of=disk.img bs=1M count=64 fi -echo "[run] Starting QEMU..." +if [ ! -f OVMF.fd ]; then + echo "[ERROR] Missing OVMF.fd. Install/copy OVMF firmware into the repo root." + exit 1 +fi + +echo "[RUN] Starting QEMU..." qemu-system-x86_64 \ -display gtk,zoom-to-fit=on \ -drive if=pflash,format=raw,readonly=on,file=OVMF.fd \ @@ -21,4 +46,4 @@ qemu-system-x86_64 \ -drive file=disk.img,if=none,id=drive0,format=raw \ -device ahci,id=ahci0 \ -device ide-hd,drive=drive0,bus=ahci0.0 \ - -serial stdio + -serial stdio \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..79384b6 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,7 @@ +[toolchain] +channel = "nightly" +targets = [ + "x86_64-unknown-uefi", + "x86_64-unknown-none", +] +components = ["rust-src"] \ No newline at end of file