Boost logo

Boost-Build :

Subject: [Boost-build] How to create and call a rule which acts differently depending on the build variant?
From: Deniz Bahadir (D.Bahadir_at_[hidden])
Date: 2009-11-11 07:58:59

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 =>
  releasestatic => libfoo_releasestatic.a
  releasedynamic =>
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
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.

Thanks in advance,

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at