From f07b29d8260836a6017e3a38dbc0646953e4304f Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Fri, 17 Nov 2017 00:46:57 +0000 Subject: [PATCH] Switch to using nake for kernel build instruction. --- .gitignore | 1 + README.md | 12 +++++++++++- buildandrun.sh | 5 ----- makefile | 13 ------------- nakefile.nim | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ nim.cfg | 10 ---------- 6 files changed, 61 insertions(+), 29 deletions(-) delete mode 100755 buildandrun.sh delete mode 100644 makefile create mode 100644 nakefile.nim delete mode 100644 nim.cfg diff --git a/.gitignore b/.gitignore index ca2fca7..cf6194f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ myos.iso *.o myos.bin serial.log +nakefile diff --git a/README.md b/README.md index 973ff12..58819c7 100644 --- a/README.md +++ b/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. diff --git a/buildandrun.sh b/buildandrun.sh deleted file mode 100755 index 0b2996c..0000000 --- a/buildandrun.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -make clean -make -./builddisc.sh -qemu-system-i386 -cdrom myos.iso -serial file:serial.log diff --git a/makefile b/makefile deleted file mode 100644 index 85af5cf..0000000 --- a/makefile +++ /dev/null @@ -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 diff --git a/nakefile.nim b/nakefile.nim new file mode 100644 index 0000000..255b39f --- /dev/null +++ b/nakefile.nim @@ -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" diff --git a/nim.cfg b/nim.cfg deleted file mode 100644 index 91bd31a..0000000 --- a/nim.cfg +++ /dev/null @@ -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"