Hi ninja-build,
I have a possible feature request, unless there's some clever way to do what I want that I can't figure out... I'm looking for a way to add one or more implicit dependencies to every "build" line that references a particular "rule".
The motivation is build tools that are themselves built as part of the build process. For example let's say I have a "foo" tool that I compile as follows:
rule cc
command = cc $in -o $out
build bin/foo : cc bin/foo.c
Now I want to use "foo" to process "bar.txt":
rule foo
command = bin/foo $in > $out
build bar : foo bar.txt
But that doesn't work correctly -- bar also needs an implicit dependency on bin/foo to ensure that the tool is compiled first:
build bar : foo bar.txt | bin/foo
If I'm using foo a lot, that gets tedious, because I need to add bin/foo to every "build" line. It's also error-prone, because if I forget to add that implicit dependency, the build *might* work but it will probably pick up stale dependencies.
It would be nice to declare the implicit dependency just once, in the rule itself:
rule foo | bin/foo
command = bin/foo $in > $out
Would it be worth adding that syntax to Ninja? Or is there already another way to do it?
I'm happy to try implementing this feature myself, but I figured I'd check here first whether it's necessary and/or useful.
Iain