Boost logo

Boost-Build :

From: Matthew Herrmann (matthew.herrmann_at_[hidden])
Date: 2007-06-28 03:13:01


Hi All,

I'd like to extract the name of the current project from a rule. I
currently can do it from with a rule defined in the same Jamfile, as
follows:

============
import project ;
project accounting ;

rule display-project-name
{
    import project ;
    local attributes = [ project.attributes $(__name__) ] ;
    local id = [ $(attributes).get id ] ;
    ECHO project name is $(id:B) ;
    # prints "accounting"
}

display-project-name ;
============

This works if I embed it in the Jamfile itself, but when I place it in a
separate utility.jam file, it fails, because $(__name__) returns
"utility", not "Jamfile</home/matth/work/src/zjam.0.0/accounting>".

If I hard-code in the Jamfile's __name__ into utility.jam, I can get the
example to work. But project.jam uses the same technique as I do, and
somehow manages to get the underlying Jamfile's name through $(__name__).

I'm doing this because I want to know the project name to pass as a
<define> variable to targets, and I want the target in a .jam file, not
defined in each Jamfile.

What am I doing wrong?

Thanks in advance,

Matthew


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