On Jul 17, 2012, at 10:55 AM, Evan Martin wrote:
> On Tue, Jul 17, 2012 at 8:09 AM, Richard Wackerbarth <
ric...@nfsnet.org> wrote:
>> A number of people have addressed ways to automatically generate version
>> numbers from the git repository (for example,
>>
http://eatmyrandom.blogspot.com/2010/06/automate-version-numbering-using-git.h
>> )
>>
>> Using make, cmake, etc. it is easy to trigger a script that determines if a
>> version header file is out of date and rewrite it when it is. That change
>> then propagates through the dependency tree.
>>
>> In attempting to use ninja, I haven't discovered any way to duplicate this
>> behavior without "wrapping the ninja build" in another build system. From
>
> Coincidentally, we're having a discussion about how to do this right here:
>
https://groups.google.com/d/topic/ninja-build/txeosqGMc6k/discussion
Interesting discussion. I will read/join in.
>
> It wouldn't be too hard to make Ninja include this information but it
> ends up being yet more complexity -- for example, we need to figure
> out what to do if git isn't available. (This is a plausible problem
> on Windows.)
The typical solution is to have a default file that does not get overwritten if a recognized scm is not available.
>> my perspective, having a mechanism to specify either sequential build phases
>> within one .ninja file,
>
> Could you elaborate on what you mean by this?
Basically, have a structured dependency scheme.
There are some rules for phase1, some for phase2, ...
In addition to the "normal" dependency rules, phase2 depends on the completion of phase1 but its other dependencies are not computed until all of phase1 has completed. Thus phase1 MIGHT alter the timestamps that affect phase2. Or it might not. Much better than the phony build scheme that always assumes that things will change.
Fundamentally, this is that same as a script that does `build phase1; build phase2; build phase3` but has all of the information in a single file.
>> or having some way in addition to filesystem
>> timestamps to specify that the output of a rule is "out-of-date" would be
>> useful.
>
> What other information would you like to key off of for judging
> whether a rule is out of date?
In general, it needs to be a script. In particular, one thing that often comes up is that an intermediate file is generated, but its content does not actually change and, as a result, the dependency chain can be broken.
> Usually you can encode such information using a stamp file in the
> filesystem. It's not as pretty as some sort of native support, but
> it's also rather standard practice for build systems and it keeps the
> number of moving parts down.
The difference in this and the scm posthook that Nico Weber describes is that posthook is a push mechanism whereas I am suggesting a pull mechanism.
Richard