Dump compiler args and defines.

As part of the build, dump the compiler arguments and defines per target
into files.
This commit is contained in:
Justin C. Miller
2019-02-07 17:39:10 -08:00
parent 863e5bda15
commit 79711be46a
2 changed files with 29 additions and 0 deletions

View File

@@ -53,12 +53,34 @@ rule cc
description = Compiling $name description = Compiling $name
command = $cc -MMD -MF $out.d $ccflags $cflags -o $out -c $in 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 rule cxx
deps = gcc deps = gcc
depfile = $out.d depfile = $out.d
description = Compiling $name description = Compiling $name
command = $cxx -MMD -MF $out.d $cxxflags $ccflags -o $out -c $in 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 rule nasm
deps = gcc deps = gcc
depfile = $out.d depfile = $out.d

View File

@@ -1,4 +1,5 @@
builddir = $builddir/{{ target }} builddir = $builddir/{{ target }}
target = {{ target }}
{% block variables %} {% block variables %}
{% endblock %} {% endblock %}
@@ -15,3 +16,9 @@ objcopy = objcopy
{% for module in modules %} {% for module in modules %}
subninja {{ module.name }}.ninja subninja {{ module.name }}.ninja
{% endfor %} {% 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 }}