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
|
|
|
|
standardOptions = """--skipCfg -d:version:"""" & execProcess("git rev-parse --abbrev-ref HEAD").strip() &
|
|
|
|
"|" & execProcess("git rev-parse HEAD").strip() & """" kernel.nim"""
|
2017-11-17 00:46:57 +00:00
|
|
|
outputFile = "myos.bin"
|
|
|
|
|
|
|
|
task "clean", "Removes build files.":
|
|
|
|
removeFile("boot.o")
|
|
|
|
removeFile("serial.log")
|
|
|
|
removeDir("nimcache")
|
2017-11-17 00:53:53 +00:00
|
|
|
removeFile(outputFile)
|
2017-11-17 00:46:57 +00:00
|
|
|
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."
|
2018-04-26 04:10:03 +01:00
|
|
|
withDir("kernel"):
|
|
|
|
direShell "nim cc -o:", "../" & outputFile, standardOptions
|
2017-11-17 00:46:57 +00:00
|
|
|
runTask("checkMultiboot")
|
|
|
|
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"):
|
|
|
|
direShell "nim cc -d:release -o:", "../" & outputFile, standardOptions
|
2017-11-17 00:46:57 +00:00
|
|
|
runTask("checkMultiboot")
|
|
|
|
echo "Done."
|
|
|
|
|
|
|
|
task "checkMultiboot", "Checks the grub multiboot header.":
|
|
|
|
echo "Checking multiboot."
|
|
|
|
direShell "grub-file --is-x86-multiboot", outputFile
|
|
|
|
echo "Multibook check successful."
|
|
|
|
|
|
|
|
task "debug", "Runs the operating system using QEMU with debug build and flags.":
|
|
|
|
runTask("build")
|
|
|
|
echo "Running in Qemu."
|
2017-11-21 19:19:45 +00:00
|
|
|
direShell "qemu-system-i386 -kernel", outputFile ,"-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")
|
|
|
|
echo "Running in Qemu."
|
|
|
|
direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio"
|