Switch to using nake for kernel build instruction.
This commit is contained in:
parent
eda795d1d8
commit
f07b29d826
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ myos.iso
|
||||
*.o
|
||||
myos.bin
|
||||
serial.log
|
||||
nakefile
|
||||
|
12
README.md
12
README.md
@ -5,9 +5,19 @@ A hobby OS written in Nim.
|
||||
|
||||
## Requirements
|
||||
* nim
|
||||
* nimble (* or use other nake install method)
|
||||
* clang
|
||||
* glibc-32
|
||||
* nasm
|
||||
* grub2
|
||||
* make
|
||||
* 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.
|
||||
|
@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
make clean
|
||||
make
|
||||
./builddisc.sh
|
||||
qemu-system-i386 -cdrom myos.iso -serial file:serial.log
|
13
makefile
13
makefile
@ -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
49
nakefile.nim
Normal 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"
|
Loading…
Reference in New Issue
Block a user