2017-11-17 00:46:57 +00:00
|
|
|
import nake
|
2018-04-28 16:01:26 +01:00
|
|
|
import os, osproc, strutils
|
2017-11-17 00:46:57 +00:00
|
|
|
|
2018-04-28 16:01:26 +01:00
|
|
|
let
|
2018-04-29 03:50:36 +01:00
|
|
|
standardOptions = """--skipCfg -d:version:"""" & execProcess("git rev-parse HEAD").strip() & """" kernel.nim"""
|
2018-05-01 20:11:14 +01:00
|
|
|
outputFile = "alcedo.bin"
|
|
|
|
outputIso = "alcedo.iso"
|
2017-11-17 00:46:57 +00:00
|
|
|
|
|
|
|
task "clean", "Removes build files.":
|
|
|
|
removeFile("boot.o")
|
|
|
|
removeFile("serial.log")
|
2018-05-01 20:11:14 +01:00
|
|
|
removeDir("kernel/nimcache")
|
|
|
|
removeDir("isodir")
|
2017-11-17 00:53:53 +00:00
|
|
|
removeFile(outputFile)
|
2018-05-01 20:11:14 +01:00
|
|
|
removeFile(outputIso)
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Done."
|
|
|
|
|
|
|
|
task "bootloader", "Builds the bootloader.":
|
|
|
|
echo "Building bootloader."
|
2018-05-01 20:11:14 +01:00
|
|
|
direShell("nasm -felf32 kernel/arch/i386/boot.s -o boot.o")
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Done."
|
|
|
|
|
|
|
|
task "build", "Builds the operating system.":
|
|
|
|
runTask("clean")
|
|
|
|
runTask("bootloader")
|
|
|
|
echo "Compiling and linking."
|
2018-04-26 04:10:03 +01:00
|
|
|
withDir("kernel"):
|
2018-05-01 20:11:14 +01:00
|
|
|
direShell("nim cc -o:../" & outputFile, standardOptions)
|
|
|
|
runTask("check-multiboot")
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Done."
|
|
|
|
|
|
|
|
task "build-release", "Builds the operating system, release mode.":
|
|
|
|
runTask("clean")
|
|
|
|
runTask("bootloader")
|
|
|
|
echo "Compiling and linking (release mode)."
|
2018-04-26 04:10:03 +01:00
|
|
|
withDir("kernel"):
|
2018-05-01 20:11:14 +01:00
|
|
|
direShell("nim cc -d:release -o:../" & outputFile, standardOptions)
|
|
|
|
runTask("check-multiboot")
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Done."
|
|
|
|
|
2018-05-01 20:11:14 +01:00
|
|
|
task "check-multiboot", "Checks the grub multiboot header.":
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Checking multiboot."
|
2018-05-01 20:11:14 +01:00
|
|
|
direShell("grub-file --is-x86-multiboot", outputFile)
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Multibook check successful."
|
|
|
|
|
2018-05-01 20:11:14 +01:00
|
|
|
task "build-disc", "Creates an ISO with the GRUB bootloader.":
|
|
|
|
removeDir("isodir")
|
|
|
|
createDir("isodir/boot/grub")
|
2018-05-02 21:18:09 +01:00
|
|
|
copyFile(outputFile, "isodir/boot/kernel")
|
2018-05-01 20:11:14 +01:00
|
|
|
copyFile("grub.cfg", "isodir/boot/grub/grub.cfg")
|
|
|
|
if not shell("grub-mkrescue -o ", outputIso, " isodir"):
|
|
|
|
direShell("grub2-mkrescue -o ", outputIso, " isodir")
|
|
|
|
|
2017-11-17 00:46:57 +00:00
|
|
|
task "debug", "Runs the operating system using QEMU with debug build and flags.":
|
|
|
|
runTask("build")
|
2018-05-01 20:11:14 +01:00
|
|
|
runTask("build-disc")
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Running in Qemu."
|
2018-05-01 20:11:14 +01:00
|
|
|
direShell("qemu-system-i386 -drive format=raw,file=" & outputIso ,"-serial stdio -no-reboot -no-shutdown -d int,cpu_reset")
|
2017-11-17 00:46:57 +00:00
|
|
|
|
|
|
|
task "run", "Runs the operating system using QEMU.":
|
|
|
|
runTask("build-release")
|
2018-05-01 20:11:14 +01:00
|
|
|
runTask("build-disc")
|
2017-11-17 00:46:57 +00:00
|
|
|
echo "Running in Qemu."
|
2018-05-01 20:11:14 +01:00
|
|
|
direShell("qemu-system-i386 -drive format=raw,file=" & outputIso ,"-serial stdio")
|