Boost logo

Boost-Build :

Subject: Re: [Boost-build] How to create and call a rule which acts differently depending on the build variant?
From: Johan Nilsson (r.johan.nilsson_at_[hidden])
Date: 2009-11-12 09:44:02


Deniz Bahadir wrote:
> Hi Johan,
>
> your solution sounds interesting but its not really what my intention
> was. (Maybe I was a little imprecise.)
> I have a lot of libraries that exist with four different
> postfix/suffix combinations, one for each build variant.
>
> libfoo1_debugstatic.a
> libfoo1_releasestatic.a
> libfoo1_debugdynamic.so
> libfoo1_releasedymaic.so
> ...
> libfoo100_debugstatic.a
> libfoo100_releasestatic.a
> libfoo100_debugdynamic.so
> libfoo100_releasedymaic.so
>
> With your solution I have to write down all 400 library-names. What I
> was planning was to just write down 100 library-base names
> (libfoo1 .... libfoo100)

Perhaps I'm dense and not following you. What about this:

path-constant LIB_PATH : relative/path/to/libs ;
local basenames = foo1 foo2 ... foon ; # Need to add the rest!

for local basename in $(basenames)
{
    lib $(basename) : : <file>$(LIB_PATH)/lib$(basename)_debugstatic.a
<variant>debugstatic ;
    lib $(basename) : : <file>$(LIB_PATH)/lib$(basename)_debugdynamic.so
<variant>debugdynamic ;
    # ... add similar for releasestatic/-dynamic ...
}

exe bar : <library>foo1 <library>foon ;

I guess it could be simplified even further, just use your imagination.

As an example, you could glob for all files matching specific patterns in
your library directories, extract the basenames and variants from their
names and automatically generate all of the above definitions.

/ Johan


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