Subject: Re: [Boost-build] How to create and call a rule which acts differently depending on the build variant?
From: Vladimir Prus (ghost_at_[hidden])
Date: 2009-11-11 09:56:56
On Wednesday 11 November 2009 Deniz Bahadir wrote:
> Hello everyone,
> I have another questions. This time it might even be pretty simple,
> but I do not know where to look for the answer:
> How can I create and call a custom-rule which acts differently
> depending on the build variant?
> For clarification I add the following example, which should explain
> the question in more detail.
> I have four build variants, "debugstatic", "debugdynamic",
> "releasestatic" and "releasedynamic". Because the libraries created by
> these variants are later copied to the same directory, their names are
> automatically adjusted, to include the build variant and correct
> suffix. So for the different build variants the filename for library
> 'foo' is (in linux):
> debugstatic => libfoo_debugstatic.a
> debugdynamic => libfoo_debugdynamic.so
> releasestatic => libfoo_releasestatic.a
> releasedynamic => libfoo_releasedynamic.so
> Now, the names of these libraries shall be used as required
> dependencies for other libraries or executables. To always include the
> correct file I could use conditional requirements like this:
> exe bar
> : bar.cpp
> : <variant>debugstatic:<file>libfoo_debugstatic.a
Are those libraries also created by Boost.Build? If so, you
probably can include the relevant target in the sources for 'bar',
as opposed to using <file>
> However, with a lot of required libraries I have to write the same
> stuff over and over again (4 times more often than I want).
> So I would like to have a rule which automatically adds the correct
> postfix and suffix to the base library name. Maybe I can do something
> similar to the following?
> rule AddCorrectPostfixAndSuffix ( name ... )
> # check the variant that gets build and add correct postfix/suffix
> exe bar
> : bar.cpp
> : <file>libfoo_at_AddCorrectPostfixAndSuffix
> The problem is, that I do not really know what the definition of such
> a rule should look like and that I do not know how to call such a
> So every possible hint to the solution is greatly appreciated.
Please take a look at indirect conditional requirements, here:
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