Boost logo

Boost-Build :

From: Phillip Seaver (phil_at_[hidden])
Date: 2007-09-04 13:53:55


Dirk Griffioen wrote, on 9/2/2007 8:30 AM:
> Hi All,
>
> I have a few bjam questions - if anyone could give me some pointers,
> that would be very much appriciated ...

You should mention which version you're using. That may change the
answer to some questions. :-)

> *1) local/global define*
>
> lib my_odbc
> : [ obj a : a.cpp ]
> [ obj b : b.cpp ]
> :<define>ODBC
> ;
>
> the define is not local so it is not used when compiling, I dont like
> having to set the define on both objs - is it possible to set it once?

Well, first off, it's not clear from your example why you're doing that
instead of this:

    lib my_odbc : a.cpp b.cpp : <define>ODBC ;

It would behave the way you want that example to. That aside, there are
a couple of options for this (that I know of). You can use a "project"
target in that file like this:

    project my_odbc : requirements <define>ODBC ;

That would affect all targets in that jamfile and any jamfiles mentioned
via "use-project" (and maybe "build-project"?). Possibly also any
jamfiles in sub-directories of that one.

Another way to do it would be with local variables:

    local defs = <define>ODBC ;
    lib my_odbc : [ obj a : a.cpp : $(defs) ] [ obj b : b.cpp : $(defs)
    ] : $(defs) ;

The idea for the inline "obj" target is that you want to compile one
object differently than the other source files. I think they
intentionally do not take build requirements from the "lib" target,
since they don't know what it is that you want to be different.

> *2) alias*
>
> I have 2 targets that are 90% alike, the only difference is they link
> to 1 different library. Now I specify 2 targets which are basically
> copies. Is it possible to define a general target once and specialize
> it for the actual case:
>
> exe base : main.cpp lib-general ;
>
> alias exe-a : base lib-a ;
> alias exe-b : base lib-b ;
>
> At the moment base is compiled/linked, this fails because some of the
> symbols is in either lib_a or lib_b

I don't believe you can do that. You should be able to do a library
that contains all the common sources and use it, though. I assume that
the reason you want to do it like that is that there are more sources
(or libs) and/or requirements that you don't want to repeat.

    lib exe-base : main.cpp lib-general ;
    exe exe-a : exe-base lib-a ;
    exe exe-b : exe-base lib-b ;

Another way you could do it:

    for local name in a b
    {
        exe exe-$(name) : main.cpp lib-general lib-$(name) ;
    }

> *3) os detection*
>
> The property <os>NT is defined, this is the only value allowed.
> However, I'd like
>
> exe my_exe : main.cpp : <os>NT <define>GREAT ;
> exe my_exe : main.cpp : <os>LINUX <define>BETTER ;
>
> Can I do this?

With the version I have, you can, which is why I said you should tell us
the version you're using. The way you would do it, though, would be:

exe my_exe : main.cpp : <os>NT:<define>GREAT <os>LINUX:<define>BETTER ;

Note the colon (":") before the <define> and that there can't be spaces
around that colon. See
http://boost.org/doc/html/bbv2/advanced.html#bbv2.advanced.targets.requirements.conditional

> *4) stage rename*
>
> I could'nt find this one:
>
> stage deliver : exe_a : <location>a <rename>base ;
>
> In other words, I'd like to give a name to an install target on
> installation.

I can't help you with "stage" -- I always use "install". From my copy
of stage.jam, it looks like you can use "<name>" to rename it when you
use the "install" target.

Phillip


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