Hello,
does Ninja somehow support rules that may not always change their output? Our use case for this is that we do have code generators that must be run if their inputs change, but they are able to detect whether the change in the input will actually result in a change of the output. For example, you may change some comments in the input file, which doesn't result in changes of the output, i.e., they do not write the output files again. That in theory allows to stop the build right there as further steps depending on the outputs do not need to be rebuild.
I tried setting up a minimal ninja example that shows the problem I have right now - and why I assume Ninja doesn't support this use case, unfortunately.
rule foo
command = cmd /c if not exist $out echo foo > $out
build second: foo first
build third: foo second
default third
Now create file 'first' and call ninja:
-> output second doesn't exist; both build statements executed.
Run ninja again:
-> No work to do
Change input file 'first' and call ninja:
-> output second older than most recent input first; second is dirty. Both build statements executed.
Without changes, run ninja again:
-> output second older than most recent input first; second is dirty. Both build statements executed.
Always writing the output file doesn't help here either, as even with unchanged content Ninja will assume the file to be changed and executes the second build statement.
Is there anything that I have missed? How do you deal with such use cases in your build setup?
Regards,
Johannes