From ee6d69bcd2d8a5c2089cd2e81fcef7ef5c81501f Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sat, 30 Mar 2019 01:33:00 -0700 Subject: [PATCH] Move builds to bonnibel 0.2 --- scripts/templates/build.ninja.j2 | 141 ++++------------------------ scripts/templates/exe.default.j2 | 8 -- scripts/templates/lib.default.j2 | 4 - scripts/templates/module.base.j2 | 41 -------- scripts/templates/target.default.j2 | 26 ----- scripts/templates/target.native.j2 | 5 + 6 files changed, 23 insertions(+), 202 deletions(-) delete mode 100644 scripts/templates/exe.default.j2 delete mode 100644 scripts/templates/lib.default.j2 delete mode 100644 scripts/templates/module.base.j2 delete mode 100644 scripts/templates/target.default.j2 diff --git a/scripts/templates/build.ninja.j2 b/scripts/templates/build.ninja.j2 index 1e33c76..c79276b 100644 --- a/scripts/templates/build.ninja.j2 +++ b/scripts/templates/build.ninja.j2 @@ -1,109 +1,14 @@ -ninja_required_version = 1.3 -builddir = {{ buildroot }} -srcroot = {{ srcroot }} -modulefile = {{ modulefile }} +{% extends "build.base.j2" %} -warnflags = $ - -Wformat=2 $ - -Winit-self $ - -Wfloat-equal $ - -Winline $ - -Wmissing-format-attribute $ - -Wmissing-include-dirs $ - -Wswitch $ - -Wundef $ - -Wdisabled-optimization $ - -Wpointer-arith $ - -Wno-attributes $ - -Wno-sign-compare $ - -Wno-multichar $ - -Wno-div-by-zero $ - -Wno-endif-labels $ - -Wno-pragmas $ - -Wno-format-extra-args $ - -Wno-unused-result $ - -Wno-deprecated-declarations $ - -Wno-unused-function $ - -Werror - -ccflags = $ +{% block variables %} +{{ super() }} +ccflags = $ccflags $ -I${srcroot}/src/include $ - -I${srcroot}/src/include/x86_64 $ - -DVERSION_MAJOR={{ version.major }} $ - -DVERSION_MINOR={{ version.minor }} $ - -DVERSION_PATCH={{ version.patch }} $ - -DVERSION_GITSHA=0x{% if version.dirty %}1{% else %}0{% endif %}{{ version.sha }} $ - -DGIT_VERSION=\"{{ version.major }}.{{ version.minor }}.{{ version.patch }}-{{ version.sha }}\" $ - -DGIT_VERSION_WIDE=L\"{{ version.major }}.{{ version.minor }}.{{ version.patch }}-{{ version.sha }}\" $ - $warnflags - -asflags = $ - -DVERSION_MAJOR={{ version.major }} $ - -DVERSION_MINOR={{ version.minor }} $ - -DVERSION_PATCH={{ version.patch }} $ - -DVERSION_GITSHA=0x{% if version.dirty %}1{% else %}0{% endif %}{{ version.sha }} - -cflags = -std=c11 -cxxflags = -std=c++14 -libs = - -rule cc - deps = gcc - depfile = $out.d - description = Compiling $name - command = $cc -MMD -MF $out.d $ccflags $cflags -o $out -c $in - -rule dump_cc_defs - description = Dumping CC defines for $target - command = echo "" | $cc $ccflags $cflags -dM -E - > $out - -rule dump_cc_run - description = Dumping CC arguments for $target - command = $ - echo "#!/bin/bash" > $out; $ - echo '$cc $ccflags $cflags $$*' > $out; $ - chmod a+x $out - -rule cxx - deps = gcc - depfile = $out.d - description = Compiling $name - command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in - -rule dump_cxx_defs - description = Dumping C++ defines for $target - command = echo "" | $cxx -x c++ $cxxflags $ccflags -dM -E - > $out - -rule dump_cxx_run - description = Dumping C++ arguments for $target - command = $ - echo "#!/bin/bash" > $out; $ - echo '$cc $cxxflags $ccflags $$*' > $out; $ - chmod a+x $out - -rule nasm - deps = gcc - depfile = $out.d - description = Assembling $name - command = $nasm -o $out -felf64 -MD $out.d $asflags $in - -rule exe - description = Linking $name - command = $ld $ldflags -o $out $in $libs - -rule lib - description = Archiving $name - command = $ar qcs $out $in - -rule regen - generator = true - description = Regenrating build files - command = {{ generator }} $builddir $modulefile - -rule cp - description = Copying $name - command = cp $in $out + -I${srcroot}/src/include/x86_64 +{% endblock %} +{% block baserules %} +{{ super() }} rule makerd description = Making init ramdisk command = $builddir/native/makerd $in $out @@ -135,27 +40,9 @@ rule strip objcopy --only-keep-debug $out $out.debug; $ strip -g $out; $ objcopy --add-gnu-debuglink=$out.debug $out +{% endblock %} -rule dump - description = Dumping decompiled $name - command = objdump -DS $in > $out - - -{% for target in targets %} -subninja {{ target }}/target.ninja -{% endfor %} - -build $ - {%- for buildfile in buildfiles %} - {{ buildfile }} $ - {%- endfor %} - : regen | $ - {%- for template in templates %} - {{ template }} $ - {%- endfor %} - $modulefile $ - {{ generator }} - +{% block extra %} build $builddir/ovmf_vars.fd : cp $srcroot/assets/ovmf/x64/ovmf_vars.fd name = ovmf_vars.fd @@ -187,5 +74,13 @@ build $builddir/popcorn.img : makefat | $ $builddir/fatroot/efi/boot/bootx64.efi name = popcorn.img +default $ + $builddir/ovmf_vars.fd $ + $builddir/ovmf_vars_d.fd $ + $builddir/popcorn.dump $ + $builddir/popcorn.elf-gdb.py $ + $builddir/popcorn.img +{% endblock %} + # vim: ft=ninja et ts=4 sts=4 sw=4 diff --git a/scripts/templates/exe.default.j2 b/scripts/templates/exe.default.j2 deleted file mode 100644 index 90c7395..0000000 --- a/scripts/templates/exe.default.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{% extends "module.base.j2" %} -{% block variables %} -{{ super() }} - -{% endblock %} - -# vim: ft=ninja et ts=4 sts=4 sw=4 - diff --git a/scripts/templates/lib.default.j2 b/scripts/templates/lib.default.j2 deleted file mode 100644 index ccc74b7..0000000 --- a/scripts/templates/lib.default.j2 +++ /dev/null @@ -1,4 +0,0 @@ -{% extends "module.base.j2" %} - -# vim: ft=ninja et ts=4 sts=4 sw=4 - diff --git a/scripts/templates/module.base.j2 b/scripts/templates/module.base.j2 deleted file mode 100644 index c01ef1e..0000000 --- a/scripts/templates/module.base.j2 +++ /dev/null @@ -1,41 +0,0 @@ -moddir = ${builddir}/{{ module.name }}.dir - -{% block variables %} -ccflags = $ccflags $ - {%- for dep in module.depmods %} - {%- for inc in dep.includes %} - -I${srcroot}/{{ inc }} $ - {%- endfor %} - {%- endfor %} - {%- for inc in module.includes %} - -I${srcroot}/{{ inc }} $ - {%- endfor %} - {%- for define in module.defines %} - -D{{ define }} $ - {%- endfor %} -{% endblock %} - -{% for source in module.sources %} -build ${moddir}/{{ source.output }} : {{ source.action }} {{ source.input }} || {{ buildfile }} - name = {{ source.name }} -{% endfor %} - -build ${builddir}/{{ module.output }} : {{ module.kind }} $ -{%- for source in module.sources %} - ${moddir}/{{ source.output }} $ -{%- endfor -%} -{%- for dep in module.libdeps %} - ${builddir}/{{ dep.output }} $ -{%- endfor %} - | $ -{% for dep in module.exedeps %} - ${builddir}/{{ dep.output }} $ -{%- endfor -%} - {{ buildfile }} - name = {{ module.name }} - -{% block extra %} -{% endblock %} - -# vim: ft=ninja et ts=4 sts=4 sw=4 - diff --git a/scripts/templates/target.default.j2 b/scripts/templates/target.default.j2 deleted file mode 100644 index 5142434..0000000 --- a/scripts/templates/target.default.j2 +++ /dev/null @@ -1,26 +0,0 @@ -builddir = $builddir/{{ target }} -target = {{ target }} - -{% block variables %} -{% endblock %} - -{% block binaries %} -cc = clang -cxx = clang++ -ld = clang++ -ar = ar -nasm = nasm -objcopy = objcopy -{% endblock %} - -{% for module in modules %} -subninja {{ module.name }}.ninja -{% endfor %} - -build ${builddir}/cc.defs : dump_cc_defs | {{ buildfile }} -build ${builddir}/cxx.defs : dump_cxx_defs | {{ buildfile }} -build ${builddir}/cc.run : dump_cc_run | {{ buildfile }} -build ${builddir}/cxx.run : dump_cxx_run | {{ buildfile }} - -# vim: ft=ninja et ts=4 sts=4 sw=4 - diff --git a/scripts/templates/target.native.j2 b/scripts/templates/target.native.j2 index e631b5c..8127cc5 100644 --- a/scripts/templates/target.native.j2 +++ b/scripts/templates/target.native.j2 @@ -1,5 +1,10 @@ {% extends "target.default.j2" %} +{% block binaries %} +{{ super() }} +ld = clang++ +{% endblock %} + {% block variables %} ccflags = $ccflags -g -ggdb