Moving to a ninja-based build system
This commit is contained in:
54
scripts/templates/build.ninja.j2
Normal file
54
scripts/templates/build.ninja.j2
Normal file
@@ -0,0 +1,54 @@
|
||||
builddir = {{ buildroot }}
|
||||
srcroot = {{ srcroot }}
|
||||
|
||||
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=\"{{ version.sha }}\" $
|
||||
-DGIT_VERSION=\"{{ version.major }}.{{ version.minor }}.{{ version.patch }}-{{ version.sha }}\"
|
||||
|
||||
asflags = $
|
||||
-DVERSION_MAJOR={{ version.major }} $
|
||||
-DVERSION_MINOR={{ version.minor }} $
|
||||
-DVERSION_PATCH={{ version.patch }} $
|
||||
-DVERSION_GITSHA=\"{{ 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 cxx
|
||||
deps = gcc
|
||||
depfile = $out.d
|
||||
description = Compiling $name
|
||||
command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in
|
||||
|
||||
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 -o $out $in $libs
|
||||
|
||||
rule lib
|
||||
description = Archiving $name
|
||||
command = $ar qcs $out $in
|
||||
|
||||
{% for target in targets %}
|
||||
subninja {{ target }}/target.ninja
|
||||
{% endfor %}
|
||||
|
||||
# vim: et ts=4 sts=4 sw=4
|
||||
|
||||
1
scripts/templates/library.default.ninja.j2
Normal file
1
scripts/templates/library.default.ninja.j2
Normal file
@@ -0,0 +1 @@
|
||||
{% extends "module.base.ninja.j2" %}
|
||||
26
scripts/templates/module.base.ninja.j2
Normal file
26
scripts/templates/module.base.ninja.j2
Normal file
@@ -0,0 +1,26 @@
|
||||
moddir = ${builddir}/{{ name }}.dir
|
||||
|
||||
{% block variables %}
|
||||
ccflags = $ccflags $
|
||||
{%- for dep in module.deps %}
|
||||
-I${srcroot}/src/libraries/{{ dep }}/include $
|
||||
{%- endfor %}
|
||||
-I${srcroot}/{{ module.path }} $
|
||||
-I${srcroot}/{{ module.path }}/include
|
||||
{% endblock %}
|
||||
|
||||
{% for source in sources %}
|
||||
build ${moddir}/{{ source.output }} : {{ source.action }} {{ source.input }}
|
||||
name = {{ source.name }}
|
||||
{% endfor %}
|
||||
|
||||
build {% block artifact %} ${builddir}/lib{{ name }}.a : lib {% endblock %} $
|
||||
{%- block extrasources %}{% endblock -%}
|
||||
{%- for source in sources %}
|
||||
${moddir}/{{ source.output }}{% if not loop.last %} ${% endif %}
|
||||
{%- endfor -%}
|
||||
{%- if module.deps %}| {% for dep in module.deps %} ${builddir}/lib{{ dep }}.a {% endfor %}{% endif %}
|
||||
name = {{ name }}
|
||||
|
||||
# End
|
||||
|
||||
18
scripts/templates/program.boot.ninja.j2
Normal file
18
scripts/templates/program.boot.ninja.j2
Normal file
@@ -0,0 +1,18 @@
|
||||
{% extends "program.default.ninja.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
cflags = $cflags $
|
||||
-DKERNEL_FILENAME=L\"popcorn.elf\" $
|
||||
-DGNU_EFI_USE_MS_ABI $
|
||||
-DHAVE_USE_MS_ABI $
|
||||
-DEFI_DEBUG=0 $
|
||||
-DEFI_DEBUG_CLEAR_MEMORY=0 $
|
||||
-fPIC $
|
||||
-fshort-wchar
|
||||
|
||||
ldflags = $ldflags $
|
||||
-shared $
|
||||
-T ${srcroot}/src/arch/x86_64/boot.ld
|
||||
|
||||
{% endblock %}
|
||||
13
scripts/templates/program.default.ninja.j2
Normal file
13
scripts/templates/program.default.ninja.j2
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "module.base.ninja.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
libs = $
|
||||
-L${builddir} $
|
||||
{%- for dep in module.deps %}
|
||||
-l{{dep}} $
|
||||
{%- endfor %}
|
||||
$libs
|
||||
|
||||
{% endblock %}
|
||||
{% block artifact %}{{ module.output }} : exe{% endblock %}
|
||||
8
scripts/templates/program.kernel.ninja.j2
Normal file
8
scripts/templates/program.kernel.ninja.j2
Normal file
@@ -0,0 +1,8 @@
|
||||
{% extends "program.default.ninja.j2" %}
|
||||
{% block variables %}
|
||||
{{ super() }}
|
||||
|
||||
asflags = $asflags -I${srcroot}/src/kernel/
|
||||
libs = $libs -lc
|
||||
|
||||
{% endblock %}
|
||||
16
scripts/templates/target.default.ninja.j2
Normal file
16
scripts/templates/target.default.ninja.j2
Normal file
@@ -0,0 +1,16 @@
|
||||
builddir = $builddir/{{ target }}
|
||||
|
||||
{% block variables %}
|
||||
{% endblock %}
|
||||
|
||||
{% block binaries %}
|
||||
cc = clang
|
||||
cxx = clang++
|
||||
ld = clang++
|
||||
ar = ar
|
||||
nasm = nasm
|
||||
{% endblock %}
|
||||
|
||||
{% for module in modules %}
|
||||
subninja {{ module }}.ninja
|
||||
{% endfor %}
|
||||
39
scripts/templates/target.host.ninja.j2
Normal file
39
scripts/templates/target.host.ninja.j2
Normal file
@@ -0,0 +1,39 @@
|
||||
{% extends "target.default.ninja.j2" %}
|
||||
{% block binaries %}
|
||||
cc = ${srcroot}/sysroot/bin/clang
|
||||
cxx = ${srcroot}/sysroot/bin/clang++
|
||||
ld = ${srcroot}/sysroot/bin/x86_64-elf-ld
|
||||
ar = ${srcroot}/sysroot/bin/x86_64-elf-ar
|
||||
nasm = ${srcroot}/sysroot/bin/nasm
|
||||
{% endblock %}
|
||||
|
||||
{% block variables %}
|
||||
|
||||
ccflags = $ccflags $
|
||||
-D__ELF__ $
|
||||
-nodefaultlibs $
|
||||
-nostdinc $
|
||||
-nostdlib $
|
||||
-ffreestanding $
|
||||
-mno-sse $
|
||||
-fno-omit-frame-pointer $
|
||||
-mno-red-zone $
|
||||
-mcmodel=large $
|
||||
-isystem${srcroot}/sysroot/include $
|
||||
--sysroot="${srcroot}/sysroot"
|
||||
|
||||
cxxflags = $cxxflags $
|
||||
-nostdlibinc $
|
||||
-isystem${srcroot}/sysroot/include/c++/v1 $
|
||||
-fno-exceptions $
|
||||
-fno-rtti
|
||||
|
||||
ldflags = $ldflags $
|
||||
-g $
|
||||
-nostdlib $
|
||||
-nostartfiles $
|
||||
-znocombreloc $
|
||||
-Bsymbolic $
|
||||
-nostartfiles
|
||||
|
||||
{% endblock %}
|
||||
1
scripts/templates/target.native.ninja.j2
Normal file
1
scripts/templates/target.native.ninja.j2
Normal file
@@ -0,0 +1 @@
|
||||
{% extends "target.default.ninja.j2" %}
|
||||
Reference in New Issue
Block a user