diff --git a/.gitignore b/.gitignore index cf6194f..d507aba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ **/nimcache/ isodir/ -myos.iso +*.iso *.o -myos.bin +*.bin serial.log nakefile + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fb98016..27ddac5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,9 +13,6 @@ compile: stage: build script: - './nakefile build' - artifacts: - paths: - - myos.bin only: - tags - triggers @@ -28,10 +25,10 @@ create_disc: script: - 'apk add xorriso grub-bios' - './nakefile build-release' - - './builddisc.sh' + - './nakefile build-disc' artifacts: paths: - - myos.iso + - alcedo.iso only: - tags - triggers diff --git a/builddisc.sh b/builddisc.sh deleted file mode 100755 index 682cdc7..0000000 --- a/builddisc.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -rm -r isodir -mkdir -p isodir/boot/grub -cp myos.bin isodir/boot/kernel -cp grub.cfg isodir/boot/grub/grub.cfg -if command -v grub-mkrescue; then - grub-mkrescue -o myos.iso isodir -elif command -v grub2-mkrescue; then - grub2-mkrescue -o myos.iso isodir -fi diff --git a/checkmultiboot.sh b/checkmultiboot.sh deleted file mode 100755 index 7aee917..0000000 --- a/checkmultiboot.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -if grub-file --is-x86-multiboot myos.bin; then - echo multiboot confirmed -else - echo the file is not multiboot -fi diff --git a/nakefile.nim b/nakefile.nim index 8f4b872..c0b5870 100644 --- a/nakefile.nim +++ b/nakefile.nim @@ -3,18 +3,21 @@ import os, osproc, strutils let standardOptions = """--skipCfg -d:version:"""" & execProcess("git rev-parse HEAD").strip() & """" kernel.nim""" - outputFile = "myos.bin" + outputFile = "alcedo.bin" + outputIso = "alcedo.iso" task "clean", "Removes build files.": removeFile("boot.o") removeFile("serial.log") - removeDir("nimcache") + removeDir("kernel/nimcache") + removeDir("isodir") removeFile(outputFile) + removeFile(outputIso) echo "Done." task "bootloader", "Builds the bootloader.": echo "Building bootloader." - direShell "nasm -felf32 kernel/arch/i386/boot.s -o boot.o" + direShell("nasm -felf32 kernel/arch/i386/boot.s -o boot.o") echo "Done." task "build", "Builds the operating system.": @@ -22,8 +25,8 @@ task "build", "Builds the operating system.": runTask("bootloader") echo "Compiling and linking." withDir("kernel"): - direShell "nim cc -o:", "../" & outputFile, standardOptions - runTask("checkMultiboot") + direShell("nim cc -o:../" & outputFile, standardOptions) + runTask("check-multiboot") echo "Done." task "build-release", "Builds the operating system, release mode.": @@ -31,21 +34,31 @@ task "build-release", "Builds the operating system, release mode.": runTask("bootloader") echo "Compiling and linking (release mode)." withDir("kernel"): - direShell "nim cc -d:release -o:", "../" & outputFile, standardOptions - runTask("checkMultiboot") + direShell("nim cc -d:release -o:../" & outputFile, standardOptions) + runTask("check-multiboot") echo "Done." -task "checkMultiboot", "Checks the grub multiboot header.": +task "check-multiboot", "Checks the grub multiboot header.": echo "Checking multiboot." - direShell "grub-file --is-x86-multiboot", outputFile + direShell("grub-file --is-x86-multiboot", outputFile) echo "Multibook check successful." +task "build-disc", "Creates an ISO with the GRUB bootloader.": + removeDir("isodir") + createDir("isodir/boot/grub") + copyFile("myos.bin", "isodir/boot/kernel") + copyFile("grub.cfg", "isodir/boot/grub/grub.cfg") + if not shell("grub-mkrescue -o ", outputIso, " isodir"): + direShell("grub2-mkrescue -o ", outputIso, " isodir") + task "debug", "Runs the operating system using QEMU with debug build and flags.": runTask("build") + runTask("build-disc") echo "Running in Qemu." - direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio -no-reboot -no-shutdown -d int,cpu_reset" + direShell("qemu-system-i386 -drive format=raw,file=" & outputIso ,"-serial stdio -no-reboot -no-shutdown -d int,cpu_reset") task "run", "Runs the operating system using QEMU.": runTask("build-release") + runTask("build-disc") echo "Running in Qemu." - direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio" + direShell("qemu-system-i386 -drive format=raw,file=" & outputIso ,"-serial stdio")