Switch to using nake for kernel build instruction.

This commit is contained in:
neviyn 2017-11-17 00:46:57 +00:00
parent eda795d1d8
commit f07b29d826
6 changed files with 61 additions and 29 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ myos.iso
*.o *.o
myos.bin myos.bin
serial.log serial.log
nakefile

View File

@ -5,9 +5,19 @@ A hobby OS written in Nim.
## Requirements ## Requirements
* nim * nim
* nimble (* or use other nake install method)
* clang * clang
* glibc-32 * glibc-32
* nasm * nasm
* grub2 * grub2
* make
* qemu * qemu
## Running
This setup uses nake to perfom build instructions.
Installation instructions for nake can be found [here](https://github.com/fowlmouth/nake#installation)
`$ nim c nakefile`
Then `$ ./nakefile debug` for debug build.
`$ ./nakefile run` for release build.

View File

@ -1,5 +0,0 @@
#!/bin/sh
make clean
make
./builddisc.sh
qemu-system-i386 -cdrom myos.iso -serial file:serial.log

View File

@ -1,13 +0,0 @@
all: kernel
release: bootloader
nim cc --skipCfg -d:release kernel/kernel.nim
kernel: bootloader
nim cc --skipCfg kernel/kernel.nim
bootloader:
nasm -felf32 kernel/arch/i386/boot.s -o boot.o
clean:
rm -r myos.bin nimcache/ boot.o serial.log

49
nakefile.nim Normal file
View File

@ -0,0 +1,49 @@
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" --out:"myos.bin" kernel/kernel.nim"""
outputFile = "myos.bin"
task "clean", "Removes build files.":
removeFile("boot.o")
removeFile("serial.log")
removeDir("nimcache")
removeFile("myos.bin")
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", 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", 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 myos.bin -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"

10
nim.cfg
View File

@ -1,10 +0,0 @@
--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"
--out:"myos.bin"