Boost logo

Boost-Build :

From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2008-02-10 13:51:47

   Hi Fredrik.

> I've been trying to figure out how to share variables across multiple
> Jamfiles, and so far I haven't found any info on how to do so. I however
> found the following statement on the boost build wiki:
[...many lines snipped...]
> I read that each Jamfile has it's own namespace, and that would explain
> why above usage doesn't work.
> But is it possible with some tricks (i.e. exporting it somehow)? If so,
> what am I missing? And if it's not possible, then what would you recommend
> me to do?

   I believe what you're looking for are the path-constant & constant
rules defined by Boost Build.

   path-constant SOURCE_BASE : "./../../../../Source" ;
   constant BOOSTVERSION : "boost_1_34_1" ;

   It is true that all Jamfiles use a separate namespace (module in
Boost Build lingo) and that is why variables from one Jamfile are not
directly accessible from other Jamfiles.

   There is also another way to achieve this which would also allow you
to make non-constant shareable variables but it takes a bit more work:
   1. Place your values in a separate module
   2. Read them from other modules using the modules.peek rule.
   3. Write to them from other modules using the modules.poke rule.


module AAA
   xxx = "Here I am!" ;

# Reading...
yyy = [ modules.peek AAA : xxx ] ;

# Writing...
modules.poke AAA : xxx : new-value ;

   constant rules work around the problem of you not knowing what a
Jamfile module is called and so not being able to access it directly as
shown above, at least not without using some internal implementation
details. What they do is ensure that a copy of their constant values is
made in each new Jamfile module. That should also explain why those
variables are 'constants' - there is actually no single variable but one
copy per Jamfile.

   path-constant rule helps with automatically rooting specified
relative paths based to your project's folder.

   Hope this helps.

   Best regards,
     Jurko Gospodnetić

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at