Boost logo

Boost-Build :

Subject: Re: [Boost-build] How to peek into the global module? / Name of the global module?
From: Deniz Bahadir (D.Bahadir_at_[hidden])
Date: 2010-02-18 13:14:28


Thanks,

that really helped.

And you were right, I did not want to access the global module, but
instead the Jamroot-module.
Sadly, for accessing the Jamroot-variable $(__name__), I am running
into the same problem as before.
However, with a little workaround (as in the following example) it worked:

module Helper-Module {
   local Jamroot-Module-Name = "" ;
}
# now store $(__name__) in Helper-Module.
local dummy = [ modules.poke Helper-Module : Jamroot-Module-Name :
$(__name__) ] ;

myVariable1 = "myVal1" ;
constant myVariable2 : "myVal2" ;

module anotherModule {
   local Jamroot-Module-Name = [ module.peek Helper-Module :
Jamroot-Module-Name ] ;
   echo "myVal1 is: " [ modules.peek $(Jamroot-Module-Name) : myVariable1 ] ;
   echo "myVal2 is: " [ modules.peek $(Jamroot-Module-Name) : myVariable2 ] ;
}

Or is there a more elegant way?

DENIZ

2010/2/18 Vladimir Prus <ghost_at_[hidden]>:
 [ snip ]
> To peek at variable in a global module you can use:
>
>        [ modules.peek : myVariable1 ] ;
>
> However, please note that global module is not the module where Jamroot lives.
> Each project file -- including Jamroot, every Jamfile and every *-config.jam
> file is a separate module. Inside such file, the name of the module can be
> obtained using $(__name__)
> Definitions made with 'constant' and 'path-constant' are automatically inherited
> in modules of child projects. E.g. 'constant' in Jamroot will be inherited by
> all Jamfiles under that Jamroot.
>
> Hope this helps,


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