Boost logo

Boost-Build :

From: Jonathan Biggar (jon_at_[hidden])
Date: 2008-07-22 12:02:55


Jurko Gospodnetić wrote:
>> Seems to me there ought to be a better way, but I haven't found one yet.
>>
>
> Well your solution seems quick good to me :-) and could be trimmed
> down to (also avoids a typo in the original example):
>
>> for local os in [ modules.peek builtin : .os-names ]
>> {
>> alias target-os-source : foo-$(os).cpp : <target-os>$(os) ;
>> }

Yup.

> But IME most often you do not have the same files on different OS's
> and then it is more useful to actually have a separate alias alternative
> for each OS.

It depends. :) Sometimes managing the alternatives by hand is ok,
sometimes it's not.

> There is also the option of providing the source file names lazily
> using indirect conditional requirements (see
> http://www.boost.org/doc/tools/build/doc/html/bbv2/advanced/targets.html#bbv2.advanced.targets.requirements)
> and the <source> property. Something like (warning: untested code):
>
>> rule add-os-specific-sources ( properties * )
>> {
>> local target-os = [ MATCH "^<target-os>(.*)$" : $(properties) ] ;
>> return
>> $(target-os)-specific-source-1
>> $(target-os)-specific-source-2
>> $(target-os)-specific-source-3
>> $(target-os)-specific-source-4
>> $(target-os)-specific-source-5 ;
>> }

Hmmm. Should that be:

rule add-os-specific-sources ( properties * )
{
     local target-os = [ MATCH "^<target-os>(.*)$" : $(properties) ] ;
     return
       <source>$(target-os)-specific-source-1
       <source>$(target-os)-specific-source-2
       <source>$(target-os)-specific-source-3
       <source>$(target-os)-specific-source-4
       <source>$(target-os)-specific-source-5 ;
}

Or am I misunderstanding something?

>> exe my-exe
>> :
>> some-fixed-source-1
>> some-fixed-source-2
>> some-fixed-source-3
>> :
>> <conditional>@add-os-specific-sources ;
>
>
> I guess what you would really like would be something like:
>
> exe my-exe
> :
> some-fixed-source-1
> some-fixed-source-2
> some-fixed-source-3
> {target-os}-specific-source-1
> {target-os}-specific-source-2
> {target-os}-specific-source-3
> {target-os}-specific-source-4
> {target-os}-specific-source-5 ;
>
> and have Boost Build dynamically construct the source file names fotr
> you, but I don't think that is possible with the current Boost Build.
> But if you can define a clear and robust syntax for achieving this
> effect feel free to suggest it on the list.

Actually, I think <conditional> handles it pretty well. Thanks!

-- 
Jon Biggar
Floorboard Software
jon_at_[hidden]
jon_at_[hidden]

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