Boost logo

Boost-Build :

From: David Abrahams (dave_at_[hidden])
Date: 2005-06-12 05:54:29


The following Jamroot says, "wherever you found the build system, the
Boost root directory is 5 directories up from there." Note the funky
way I went up 5 directories. Hmm, now I feel dumb; probably appending
/../../../../.. would have worked, right? Still, peeking for
.bootstrap-file seems a little kludgey...

=== Jamroot===
import modules ;
import os ;
import path ;

import mtl4 ;

path-constant mtl4-css : default.css ;

.bootstrap-file = [ path.make [ modules.peek : .bootstrap-file ] ] ;
.boost = $(.bootstrap-file) ;
for local x in 1 2 3 4 5
{
.boost = [ path.parent $(.boost) ] ;
}
.boost = [ path.native $(.boost) ] ;

project mtl4 : requirements <include>. <include>$(.boost) ;

use-project /boost : $(.boost) ;

===

Okay, here's another. This rule is a common rule meant to be called
from a Jamfile. Note the extensive use of backtrace and peeking into
other modules in order to do simple things like access path variables
and declare targets!

rule build-local-docs ( )
{
import boostbook ;
import docutils ;
import path ;
import modules ;

# Where is the calling Jamfile located?
local bt = [ BACKTRACE 2 ] ;
local caller-dir = [ path.make $(bt[5]:D) ] ;

# Find the sources and locate relative to caller-dir so that I can call
# target rules on them.
local misplaced-sources = [ path.glob $(caller-dir) : *.rst ] ;
local sources ;
for local s in $(misplaced-sources)
{
sources += [ path.relative-to $(caller-dir) $(s) ] ;
}

# Strip the extension
local bases = [ MATCH (.*)\.rst$ : $(sources) ] ;

local caller-module = [ MATCH (.*)\.$ : $(bt[7]) ] ;
local css = [ modules.peek $(caller-module) : mtl4-css ] ;

for local src in $(bases)
{
html $(src) : $(src).rst :
<docutils-html>"-gdt --traceback --trim-footnote-reference-space --embed-stylesheet --stylesheet-path="$(css)
;
}

alias htmls : $(bases) ;
stage html : $(bases) ;
}

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com
 

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