alcedo/nakefile.nim

50 lines
1.7 KiB
Nim

import nake
import os
const
standardOptions = """--skipCfg --forceBuild --cc:clang --deadCodeElim:on --gc:regions --boundChecks:on --path:"kernel/arch/i386" --cpu:i386 --os:standalone --passC:"-ffreestanding -nostdlib --target=i386-pc-none-elf -march=i386" --passL:"-ffreestanding -target i386 -nostdlib" kernel/kernel.nim"""
outputFile = "myos.bin"
task "clean", "Removes build files.":
removeFile("boot.o")
removeFile("serial.log")
removeDir("nimcache")
removeFile(outputFile)
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."
direShell "nim cc -o:", outputFile, standardOptions
runTask("checkMultiboot")
echo "Done."
task "build-release", "Builds the operating system, release mode.":
runTask("clean")
runTask("bootloader")
echo "Compiling and linking (release mode)."
direShell "nim cc --skipCfg -d:release -o:", outputFile, standardOptions
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."
direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio -no-reboot -d int,cpu_reset"
task "run", "Runs the operating system using QEMU.":
runTask("build-release")
echo "Running in Qemu."
direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio"