From 79711be46a76e5ecc64894bc1832637d5e34efe3 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Thu, 7 Feb 2019 17:39:10 -0800 Subject: [PATCH] Dump compiler args and defines. As part of the build, dump the compiler arguments and defines per target into files. --- scripts/templates/build.ninja.j2 | 22 ++++++++++++++++++++++ scripts/templates/target.default.j2 | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/scripts/templates/build.ninja.j2 b/scripts/templates/build.ninja.j2 index c80da08..2c57dc6 100644 --- a/scripts/templates/build.ninja.j2 +++ b/scripts/templates/build.ninja.j2 @@ -53,12 +53,34 @@ rule cc 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 diff --git a/scripts/templates/target.default.j2 b/scripts/templates/target.default.j2 index 93098ef..31c9191 100644 --- a/scripts/templates/target.default.j2 +++ b/scripts/templates/target.default.j2 @@ -1,4 +1,5 @@ builddir = $builddir/{{ target }} +target = {{ target }} {% block variables %} {% endblock %} @@ -15,3 +16,9 @@ objcopy = objcopy {% 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 }} +