Boost logo

Boost-Build :

From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2008-04-29 08:38:07


   Hi Xavier.

> yes, I want also a library with the contents of A and B. Something like
> this:
>
> lib ABgrouped
> :
> A.cpp
> B.cpp
> : :
> : <include>. ;
>
> But only managing the source files A.cpp and B.cpp in a unique place.

   So what is wrong with something like this?

lib A
   :
   A.cpp
   : :
   : <include>. ;

lib B
   :
   B.cpp
   : :
   : <include>. ;

lib AB
   :
   A.cpp
   B.cpp
   : :
   : <include>. ;

   As far as I can see - the duplication is minimal - just enough to say
what you want to say.

   On the other hand, since this is a simple example with only a single
source file per library, perhaps a more realistic one would be:

lib A
   :
   A1.cpp
   A2.cpp
   A3.cpp
   : :
   : <include>. ;

lib B
   :
   B1.cpp
   B2.cpp
   B3.cpp
   : :
   : <include>. ;

lib AB
   :
   A1.cpp
   A2.cpp
   A3.cpp
   B1.cpp
   B2.cpp
   B3.cpp
   : :
   : <include>. ;

   I which case the duplication becomes more apparent but it can be
reduced to the previous example by introducing 2 additional alias for
library A and library B sources:

alias libASources
   :
   A1.cpp
   A2.cpp
   A3.cpp ;

alias libBSources
   :
   B1.cpp
   B2.cpp
   B3.cpp ;

lib A
   :
   libASources
   : :
   : <include>. ;

lib B
   :
   libBSources
   : :
   : <include>. ;

lib AB
   :
   libASources
   libBSources
   : :
   : <include>. ;

   And duplication again goes back to minimum.

   I guess this needs some of the targets being made explicit, and
depending on your exact project needs could be better organized by
introducing some helper wrapper rules but that is another story...

   I do not think there is a public Boost Build primitive that would
allow to say: for this target use all the sources used for that target.
If we had that you could say something like:

lib A
   :
   A.cpp
   : :
   : <include>. ;

lib B
   :
   B.cpp
   : :
   : <include>. ;

lib AB
   :
   [ sourcesOf A ]
   [ sourcesOf B ]
   : :
   : <include>. ;

   I guess this would allow for a cleaner syntax in your case. YMMV, but
I am not sure the added complexity (for an average Boost Build user)
would be worth it nor that it would not allow the user new ways to shoot
himself in the foot. :-)

   Hope this helps.

   Best regards,
     Jurko Gospodnetić


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