Compare commits

..

No commits in common. "0485052b1150e9e59a50ad4ea7d29ac53900f0ee" and "1afc66acb18f670c9c1c9c2f629e53889217df7f" have entirely different histories.

6 changed files with 35 additions and 52 deletions

3
.gitignore vendored
View File

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

View File

@ -1,38 +0,0 @@
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

@ -28,21 +28,12 @@ Licensed under the GNU Public License v3. See [LICENSE](LICENSE) for details.
To build an ISO image that you can boot, there are several prerequisites:
- `rustup` command installed
- `limine` command installed
- `xorriso` command installed
- `make` command installed
- `qemu-system-x86_64` command installed (for running)
Then run `make` to invoke the [Makefile](Makefile).
Then run the [build_iso.sh](build_iso.sh) script. It will generate `gila.iso`.
- `make prepare`: Installs needed Rust toolchain.
- `make clean`: Cleans all built files.
- `make gila`: Builds the kernel ELF file.
- `make iso`: Builds the bootable ISO with Limine installed.
- `make run`: Builds the ISO and boots it in QEMU.
TODO: This build setup is not compatible with anything other than `x86_64`.
Running the kernel requires `qemu-system-{ARCH}`.
You can install all these dependencies automatically by using `nix-shell` and
supplying [shell.nix](shell.nix) as an argument.

31
build_iso.sh Executable file
View File

@ -0,0 +1,31 @@
#!/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

@ -16,7 +16,6 @@ pkgs.mkShell {
xorriso
rustup
qemu
make
];

View File

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