|
Boost-Build : |
Subject: Re: [Boost-build] Understanding generated files / targets.
From: Tom (tabsoftwareconsulting_at_[hidden])
Date: 2014-07-28 00:18:07
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'. This has become
> > necessary as we have moved to git and a branched development model and
> > modifying a version file manually is a non-starter (due to conflicts
> > on merg) in this development model. We will be driving the version
> > number in binaries by tags in revision control.
> >
> > This is challenging mainly in that the generated file depends on state
> > not known (or knowable) by Boost.Build as opposed to a normal file
> > transformation. This results in either not generating the file when
> > it should be (a tag is checked out or a file is edited which do not
> > affect the code handling the version number, then the build is run) or
> > in rebuilding things when it is not actually necessary (which causes
> > all tests to be re-run for example).
>
> 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)
Steven,
That worked really well, I wish I knew that little trick before :)
It took a little while for me to get it right, so I've included a minimal
Jamroot that shows how it was done for others that might need
something like this.
Thanks!
Tom
# Jamroot
import print ;
explicit generated ;
exe generated : generated.cpp ;
explicit generated.cpp ;
make generated.cpp : : @generate-file ;
rule generate-file ( target : sources * : properties * )
{
print.output $(target) ;
print.text "int main() { return 0; }
" : true ;
}
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