|
Boost-Build : |
From: Vladimir Prus (ghost_at_[hidden])
Date: 2006-02-10 03:46:08
Hi Daniel,
> I was looking at this piece of Jamfile again:
> alias linux ;
> obj linux
>
> : # sources
>
> linux.cpp
>
> : # requirements
>
> <os>LINUX
> ;
.......
> ========== Example 2 ==========
> rule platform-specific-source ( )
> {
> import os ;
> local files ;
> switch [ os.name ]
> {
> case NT : ;
> case LINUX :
> files += linux.cpp
> ;
> case OSXPPC :
> files += osxppc.cpp
> ;
> }
> return $(files) ;
> }
>
> exe example2 : [ platform-specific-source ] ;
That's just fine, if the build platform and the target platforms is the same
-- which is the case now since we don't, at least officially, support
cross-compiling.
> and it almost works, but since we don't have any NT specific files, the
> rule bombs out.
Ah, true, but what do you want in that case? Skip building of 'example2'
completely? Then, you can either wrap it in "if [ os.name ] = NT", or you can
use newly introduced <build>no properties:
exe example2 : [ platform-specific-source ] : <os>NT:<build>no ;
or you can combine indirect conditional requirements with <build>on and the
<source> feature like this:
rule sources ( properties * )
{
if <variant>debug in $(properties)
{
return <source>a_d.cpp ;
}
else if <variant>release in $(properties)
{
return <source>a_r.cpp ;
}
else
{
return <build>no ;
}
}
exe main : : <conditional>@sources ;
I've used <varint> for testing, you'll use <os> feature. Here's what I get:
ghost_at_zigzag$ bjam debug
[...]
gcc.compile.c++ bin/gcc/debug/a_d.o
[...]
ghost_at_zigzags$ bjam release
[...]
gcc.compile.c++ bin/gcc/release/a_r.o
[...]
ghost_at_zigzag:/space/p2/ghost/build/boost.build/sources$ bjam profile
Skipping build of ./main -- <build>no in properties.
HTH,
Volodya
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