Subject: Re: [Boost-build] Newbie Q
From: Alex Richardson (alexrichardson_at_[hidden])
Date: 2009-02-02 14:37:58
On Mon, Feb 2, 2009 at 12:11 PM, Reynolds, John
> Is there any way to run a notfile or make target before a lib target is run as they seem to run after lib target.
> I am trying to extract sources from a compressed file before doing a glob-tree. If someone has a recipe that do this, I would be much obliged.
> Trying to do something like,
> rule extract_src ( )
> echo "Extracting sources" ;
> actions extract_src
> "./gzip" -xvf $(>)
> extract_src ;
> lib xyz : [ glob-tree *.c ] ;
(Someone correct me if I'm wrong here, still a bit new to boost build myself.)
I have needed this same capability and would love to hear if there is
a 'right' way to do this. I wasted a lot of work trying to use a
notfile rule etc... but finally understood that this just plain
doesn't work for extracting src files.
The first thing to understand is that bjam does not simply step
through your jamfiles and build targets as they are encountered.
Instead, as bjam reads through your file, it reads each target rule
and adds it to its internal dependency model. Next, bjam determines
which targets need to be run, then finally runs those rules. The
problem arises that your rule (extract_src) needs to run before bjam
can build the complete dependency tree. What you really need is to
ensure that the src is extracted before bjam even starts.
What I do to get around this problem is that I write a small shell
script which will extract my src if it hasn't already been extracted.
(For example, I have a project where I uses the boost libraries, so I
put the tarball for boost in my src directory, and then I have an
extract_boost.sh shell script which checks to see fi the boost
diercoty already exists, and if not, it extracts it. I am including
the contents of the shell script below:
# If needed, extract the boost build archive.
if [ ! -e "boost_1_37_0" ] ; then
echo "#### Extracting boost from boost_1_37_0.tar.bz2 ####"
if ( tar -xjf boost_1_37_0.tar.bz2 ) ; then
echo "Extracted boost successfully"
echo "Failed to extract boost!"
Next, at the top of my Jamroot file I have the lines:
path-constant SRC_DIR : . ;
SHELL "( cd $(SRC_DIR) && ./extract_boost.sh )" ;
Unlike a 'target' rule, bjam runs the 'SHELL' rule/command as soon as
it is encountered. So as bjam starts to read through my Jamroot file
to gether targets, the first thing it does is to run my shell script.
Anyway, I hope this helps. Everyone else is welcome to correct/clarify
P.S. (I just noticed that Volodya responded as well, what I describe
above is basicly the same thing he is suggesting I think)
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