From: Jurko Gospodnetić (jurko.gospodnetic_at_[hidden])
Date: 2008-05-18 06:39:50


   Hi Adder.

> In toolset/borland.jam (or a similar file), I need to modify
>
> rule link ( targets + : sources * : properties * )
> {
> ....
> }
>
> in order to extract the sources of type OBJ in a separate variable.
>
> I tried using:
>
> echo [ virtual-target.select-by-type OBJ : $(sources) ] ;
>
> but I'm getting an error when building. On further investigation, it
> turns out that $(sources[1]) is something like this:
>
> <p!-Bin\borland-5.6.0\debug\link-static\runtime-link-static\threading-multi\user-interface-gui\xcharset-ansi>Main.obj
>
> and it doesn't have a .type property (required by select-by-type).
> It's not a "virtual target" object !
>
> How can I get the OBJ sources in a variable, so I can use it in the
> "actions link ..." code ?

   I do not believe there is a 'clean' way to do what you want directly
from the final target building rule like that. That rule gets only the
Boost Jam target names representing all of the sources used. I guess you
could parse those names to recognize .obj targets but that would not be
a very robust solution since Boost Build offers no guarantees that it
will construct those names the same in future versions.

   What you can do is implement a new generator class. In its run rule
you get all the source targets as Boost Build's virtual-target objects
which you can then easily analyze to see if they are typed targets and
what their type is. See the comments in generators.jam & targets.jam to
get you started but as I recall that rule returns a list whose first
parameter is a property-set object representing usage requirements to be
applied to all dependent targets and the rest is the list of newly
generated virtual targets.

   Hope this helps.

   Best regards,
     Jurko Gospodnetić