Ninja buildsystem produces working bootloader

This commit is contained in:
Justin C. Miller
2019-02-02 18:24:58 -08:00
parent a1fe745a53
commit acdca19f59
6 changed files with 47 additions and 9 deletions

View File

@@ -14,9 +14,9 @@ MODULES = {
"makerd": program('src/tools/makerd', ["initrd", "kutil"], "makerd", ["native"]), "makerd": program('src/tools/makerd', ["initrd", "kutil"], "makerd", ["native"]),
"nulldrv": program('src/drivers/nulldrv', [], "nulldrv", ["host"]), "boot": program('src/boot', [], "boot.elf", ["boot"]),
"boot": program('src/boot', ["elf"], "boot.elf", ["host"]), "nulldrv": program('src/drivers/nulldrv', [], "nulldrv", ["host"]),
"kernel": program('src/kernel', ["elf", "initrd", "kutil"], "popcorn.elf", ["host"]), "kernel": program('src/kernel', ["elf", "initrd", "kutil"], "popcorn.elf", ["host"]),
} }

View File

@@ -65,7 +65,7 @@ rule nasm
rule exe rule exe
description = Linking $name description = Linking $name
command = $ld -o $out $in $libs command = $ld $ldflags -o $out $in $libs
rule lib rule lib
description = Archiving $name description = Archiving $name
@@ -127,7 +127,7 @@ build $builddir/popcorn.fat : cp $srcroot/assets/ovmf/x64/OVMF.fd
build $builddir/fatroot/popcorn.elf : cp $builddir/host/popcorn.elf build $builddir/fatroot/popcorn.elf : cp $builddir/host/popcorn.elf
name = kernel to FAT image name = kernel to FAT image
build $builddir/fatroot/efi/boot/bootx64.efi : cp $builddir/host/boot.efi build $builddir/fatroot/efi/boot/bootx64.efi : cp $builddir/boot/boot.efi
name = bootloader to FAT image name = bootloader to FAT image
build $builddir/fatroot/initrd.img : makerd ${srcroot}/assets/initrd.toml | $ build $builddir/fatroot/initrd.img : makerd ${srcroot}/assets/initrd.toml | $

View File

@@ -2,7 +2,11 @@
{% block variables %} {% block variables %}
{{ super() }} {{ super() }}
cflags = $cflags $ ld = ld
cc = clang
cxx = clang++
ccflags = $ccflags $
-DKERNEL_FILENAME=L\"popcorn.elf\" $ -DKERNEL_FILENAME=L\"popcorn.elf\" $
-DGNU_EFI_USE_MS_ABI $ -DGNU_EFI_USE_MS_ABI $
-DHAVE_USE_MS_ABI $ -DHAVE_USE_MS_ABI $
@@ -12,8 +16,8 @@ cflags = $cflags $
-fshort-wchar -fshort-wchar
ldflags = $ldflags $ ldflags = $ldflags $
-shared $ -T ${srcroot}/src/arch/x86_64/boot.ld $
-T ${srcroot}/src/arch/x86_64/boot.ld -shared
{% endblock %} {% endblock %}

View File

@@ -3,7 +3,7 @@
{{ super() }} {{ super() }}
asflags = $asflags -I${srcroot}/src/kernel/ asflags = $asflags -I${srcroot}/src/kernel/
libs = $libs -lc libs = $libs
ldflags = $ldflags -T ${srcroot}/src/arch/x86_64/kernel.ld ldflags = $ldflags -T ${srcroot}/src/arch/x86_64/kernel.ld
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,35 @@
{% extends "target.default.ninja.j2" %}
{% block binaries %}
ld = ld
cc = clang
cxx = clang++
nasm = nasm
{% endblock %}
{% block variables %}
ccflags = $ccflags $
-ggdb $
-nostdlib $
-ffreestanding $
-nodefaultlibs $
-fno-builtin $
-mno-sse $
-fno-omit-frame-pointer $
-mno-red-zone
cxxflags = $cxxflags $
-nostdlibinc $
-isystem${srcroot}/sysroot/include/c++/v1 $
-fno-exceptions $
-fno-rtti
ldflags = $ldflags $
-g $
-nostdlib $
-znocombreloc $
-Bsymbolic $
-nostartfiles
{% endblock %}

View File

@@ -35,7 +35,6 @@ ldflags = $ldflags $
-nostdlib $ -nostdlib $
-nostartfiles $ -nostartfiles $
-znocombreloc $ -znocombreloc $
-Bsymbolic $
-nostartfiles -nostartfiles
{% endblock %} {% endblock %}