Boost logo

Boost-Build :

Subject: Re: [Boost-build] Understanding generated files / targets.
From: Tom (tabsoftwareconsulting_at_[hidden])
Date: 2014-10-08 11:15:46


Phillip Seaver <phil <at> apago.com> writes:

>
> On 7/28/14 12:18 AM, Tom wrote:
> > Steven Watanabe <watanabesj <at> gmail.com> writes:
> >
> >> On 07/27/2014 12:42 PM, Tom wrote:
> >>> I am trying to generate a C++ source (or header) file containing
> >>> versioning information generated from 'git describe'.
> >> If you can use the print module to generate the file,
> >> then it automatically checks whether the content has
> >> changed. (See b2 --help print for information on
> >> how to use it)
> >
> > # Jamroot
> > import print ;
> >
> > explicit generated ;
> > exe generated : generated.cpp ;
> > explicit generated.cpp ;
> > make generated.cpp : : <at> generate-file ;
> > rule generate-file ( target : sources * : properties * )
> > {
> > print.output $(target) ;
> > print.text "int main() { return 0; }
> > " : true ;
> > }
>
> I'm trying to do something similar. If the file wouldn't change, it
> doesn't get updated, right? Does that mean the lib or exe that depends
> on it doesn't get recompiled as well? (which is what I would want). Or
> does everything get recompiled?

The Jamfile above is complete and works just like this for me with
Boost.Build from Boost 1.51.0 and many others after that. I have
not yet updated, so I'm not sure if it works all the way up to the latest
Boost.

The "<at> generate-file" above should be replaced with "@generate-file".

> It doesn't work with my older boost-build (~10 months old), so I haven't
> been able to test it. It will find an action but not a rule named in
> the 'make' options, at least in my experiments. It could be because the
> rule is in a file I import (as is the 'make' usage).

Can you post your actual work? The file above works for me for

1.51.0, 1.52.0, 1.53.0, 1.54.0, 1.55.0.

> If that doesn't work the way I would like (nothing gets rebuilt if the
> generated file wouldn't change, is there a way to do that?

It works just like you'd hope.

Tom


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk