Replace shell script with makefile

This commit is contained in:
River 2025-02-11 23:31:16 -05:00
parent 1afc66acb1
commit f339c707b7
Signed by: shibedrill
GPG Key ID: 5FE0CB25945EFAA2
4 changed files with 40 additions and 33 deletions

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
/target
/iso
/gila.iso
/build

38
Makefile Normal file
View File

@ -0,0 +1,38 @@
TARGET ?= "x86_64-unknown-none"
all: clean prepare gila iso run
# Prepare toolchain
prepare:
rustup install nightly
rustup target add $(TARGET)
# Run the ISO in an emulator.
run: build/gila.iso
qemu-system-x86_64 -drive file=build/gila.iso,format=raw,index=0,media=disk
# Build the bootable kernel image.
.PHONY: build/iso/gila
gila: prepare $(wildcard src/*.rs)
mkdir -p build/iso/
cargo build --release -Z unstable-options --target=$(TARGET) --artifact-dir build/iso/
# Build a bootable ISO and install Limine.
.PHONY: build/gila.iso
iso: build/iso/gila gila limine.conf
mkdir -p build/iso/limine
mkdir -p build/iso/EFI/BOOT
cp ./limine.conf build/iso/
cp /usr/share/limine/limine-bios.sys build/iso/limine/
cp /usr/share/limine/limine-bios-cd.bin build/iso/limine/
cp /usr/share/limine/limine-uefi-cd.bin build/iso/limine/
xorriso -as mkisofs -b limine/limine-bios-cd.bin -no-emul-boot \
-boot-load-size 4 -boot-info-table --efi-boot \
limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image \
--protective-msdos-label build/iso -o build/gila.iso
limine bios-install build/gila.iso
clean:
rm -rf build
cargo clean

View File

@ -1,31 +0,0 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Argument 1 must be the Rust target triple."
exit 1
fi
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1 ; pwd -P )"
cd "$SCRIPTPATH" || exit 1
rm -rf ./iso/
rm ./gila.iso
#cargo clean
set -euxo pipefail
mkdir -p ./iso/limine/
cp ./limine.conf ./iso/
cp /usr/share/limine/limine-bios.sys ./iso/limine/
cp /usr/share/limine/limine-bios-cd.bin ./iso/limine/
cp /usr/share/limine/limine-uefi-cd.bin ./iso/limine/
cargo build --target="$1" --release
cp target/"$1"/release/gila ./iso/
xorriso -as mkisofs -b limine/limine-bios-cd.bin -no-emul-boot \
-boot-load-size 4 -boot-info-table --efi-boot \
limine/limine-uefi-cd.bin -efi-boot-part --efi-boot-image \
--protective-msdos-label iso -o gila.iso
limine bios-install gila.iso

View File

@ -1,4 +1,5 @@
#![allow(dead_code)]
#![allow(unused_variables)]
use vga;
pub use vga::writers::TextWriter;