Moved external scripts into nakefile.

This commit is contained in:
neviyn 2018-05-01 20:11:14 +01:00
parent fad439c25e
commit f375ef47c5
5 changed files with 29 additions and 34 deletions

5
.gitignore vendored
View File

@ -1,7 +1,8 @@
**/nimcache/
isodir/
myos.iso
*.iso
*.o
myos.bin
*.bin
serial.log
nakefile

View File

@ -13,9 +13,6 @@ compile:
stage: build
script:
- './nakefile build'
artifacts:
paths:
- myos.bin
only:
- tags
- triggers
@ -28,10 +25,10 @@ create_disc:
script:
- 'apk add xorriso grub-bios'
- './nakefile build-release'
- './builddisc.sh'
- './nakefile build-disc'
artifacts:
paths:
- myos.iso
- alcedo.iso
only:
- tags
- triggers

View File

@ -1,10 +0,0 @@
#!/bin/sh
rm -r isodir
mkdir -p isodir/boot/grub
cp myos.bin isodir/boot/kernel
cp grub.cfg isodir/boot/grub/grub.cfg
if command -v grub-mkrescue; then
grub-mkrescue -o myos.iso isodir
elif command -v grub2-mkrescue; then
grub2-mkrescue -o myos.iso isodir
fi

View File

@ -1,6 +0,0 @@
#!/bin/sh
if grub-file --is-x86-multiboot myos.bin; then
echo multiboot confirmed
else
echo the file is not multiboot
fi

View File

@ -3,18 +3,21 @@ import os, osproc, strutils
let
standardOptions = """--skipCfg -d:version:"""" & execProcess("git rev-parse HEAD").strip() & """" kernel.nim"""
outputFile = "myos.bin"
outputFile = "alcedo.bin"
outputIso = "alcedo.iso"
task "clean", "Removes build files.":
removeFile("boot.o")
removeFile("serial.log")
removeDir("nimcache")
removeDir("kernel/nimcache")
removeDir("isodir")
removeFile(outputFile)
removeFile(outputIso)
echo "Done."
task "bootloader", "Builds the bootloader.":
echo "Building bootloader."
direShell "nasm -felf32 kernel/arch/i386/boot.s -o boot.o"
direShell("nasm -felf32 kernel/arch/i386/boot.s -o boot.o")
echo "Done."
task "build", "Builds the operating system.":
@ -22,8 +25,8 @@ task "build", "Builds the operating system.":
runTask("bootloader")
echo "Compiling and linking."
withDir("kernel"):
direShell "nim cc -o:", "../" & outputFile, standardOptions
runTask("checkMultiboot")
direShell("nim cc -o:../" & outputFile, standardOptions)
runTask("check-multiboot")
echo "Done."
task "build-release", "Builds the operating system, release mode.":
@ -31,21 +34,31 @@ task "build-release", "Builds the operating system, release mode.":
runTask("bootloader")
echo "Compiling and linking (release mode)."
withDir("kernel"):
direShell "nim cc -d:release -o:", "../" & outputFile, standardOptions
runTask("checkMultiboot")
direShell("nim cc -d:release -o:../" & outputFile, standardOptions)
runTask("check-multiboot")
echo "Done."
task "checkMultiboot", "Checks the grub multiboot header.":
task "check-multiboot", "Checks the grub multiboot header.":
echo "Checking multiboot."
direShell "grub-file --is-x86-multiboot", outputFile
direShell("grub-file --is-x86-multiboot", outputFile)
echo "Multibook check successful."
task "build-disc", "Creates an ISO with the GRUB bootloader.":
removeDir("isodir")
createDir("isodir/boot/grub")
copyFile("myos.bin", "isodir/boot/kernel")
copyFile("grub.cfg", "isodir/boot/grub/grub.cfg")
if not shell("grub-mkrescue -o ", outputIso, " isodir"):
direShell("grub2-mkrescue -o ", outputIso, " isodir")
task "debug", "Runs the operating system using QEMU with debug build and flags.":
runTask("build")
runTask("build-disc")
echo "Running in Qemu."
direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio -no-reboot -no-shutdown -d int,cpu_reset"
direShell("qemu-system-i386 -drive format=raw,file=" & outputIso ,"-serial stdio -no-reboot -no-shutdown -d int,cpu_reset")
task "run", "Runs the operating system using QEMU.":
runTask("build-release")
runTask("build-disc")
echo "Running in Qemu."
direShell "qemu-system-i386 -kernel", outputFile ,"-serial stdio"
direShell("qemu-system-i386 -drive format=raw,file=" & outputIso ,"-serial stdio")