import nake import os, osproc, strutils let standardOptions = """--skipCfg -d:version:"""" & execProcess("git rev-parse HEAD").strip() & """" kernel.nim""" outputFile = "alcedo.bin" outputIso = "alcedo.iso" task "clean", "Removes build files.": removeFile("boot.o") removeFile("serial.log") 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") echo "Done." task "build", "Builds the operating system.": runTask("clean") runTask("bootloader") echo "Compiling and linking." withDir("kernel"): direShell("nim cc -o:../" & outputFile, standardOptions) runTask("check-multiboot") echo "Done." task "build-release", "Builds the operating system, release mode.": runTask("clean") runTask("bootloader") echo "Compiling and linking (release mode)." withDir("kernel"): direShell("nim cc -d:release -o:../" & outputFile, standardOptions) runTask("check-multiboot") echo "Done." task "check-multiboot", "Checks the grub multiboot header.": echo "Checking multiboot." 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(outputFile, "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 -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 -drive format=raw,file=" & outputIso ,"-serial stdio")