Boost logo

Boost-Build :

From: Rene Rivera (grafik666_at_[hidden])
Date: 2002-08-27 10:56:48


[2002-08-27] Patrick Frants wrote:

>Hi,
>
>I am using templates to factor out common compiler options.
>
>I have declared some templates in the Jamfile in the project root. When I
>try to use them in a Jamfile in a subdirectory I don't get any errors, but
>all the settings of the templates are lost. When I move the template
>declarations to the Jamfile in the subdirectory there are no problems. How
>can I avoid copying the templates to each of the Jamfiles in the
>subdirectories?

I manage to use templates declared at my root in my subprojects. I think the
problem you might be running into is a variable expansion problem. Because
of scoping issues if you are using variables in the template declaration the
template options may be getting expanded to empty. For example:

TOP level Jamfile...

project-root ;
PWDDIR = [ PWD ] ;
template t : : <include>$(PWDDIR) : ;

Subdir Jamfile...

subproject sub ;
exe : <template>../t main.cpp : : ;

The template in the subdir will expand to nothing because the PWDDIR
variable is scoped to the top level Jamfile only. This is actualy a recent
change to deal with local vs. global variables.

One option is to put such variables in your Jamrules file which is declared
at the global scope. This is what I do personally.

Another is to declare them in the global scope manually like so:

module { PWDDIR = [ PWD ] ; }

>Are the paths declared in the template relative too the Jamfile that the
>template is in or relative to the Jamfile the template is used in? In other
>words is the template text copied flat from the template or not. I assume
>the answer is the same for $(SUBDIR) etc. then.

No, template text is not copied flat. Any specs in the template that refer
to paths are translated(re-rooted) so that paths look like they are always
relative to where the template was declared.

-- grafik - Don't Assume Anything
-- rrivera_at_[hidden] - grafik_at_[hidden]
-- 102708583_at_icq - Grafik666_at_AIM - Grafik_at_[hidden]

 


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