|
Boost-Build : |
From: Jonathan Biggar (jon_at_[hidden])
Date: 2008-07-26 14:10:54
Jurko GospodnetiÄ wrote:
>> I would like to have a flat directory structure:
>>
>> .../build/*.*
>>
>> as opposed to
>>
>> .../build/debug/threading-multi/*.*
>
> I do not believe this is the wanted behaviour for Boost Build based
> builds so I do not think there is an easy way to achieve this. The only
> thing that pops to mind is hacking Boost Build's functionality for
> constructing the target folder name, but I really do not see the point.
>
> If you do not separate different build variants... you forfeit most
> Boost Build features... E.g. no multiple-variant builds (debug/release)
> and you have to clean the build results before building a different variant.
>
> Having different variants split over multiple folders should not
> present problems... you should rarely if ever need to manually locate
> intermediate results stored there. Use the install rule to move final
> products into specific external folders.
In general, I agree with you, but there are specific cases where this
causes problems. For example, the project I'm working on generated C++
header files that need to be installed. If the header file gets
generated four times for debug/release and multi-/single-threaded
variants, which one should be installed if I want to install all four
variant libraries?
I've worked up a patch that does the trick for me. It defines a new
feature "<ignore-feature>", which allows the user to specify other
features that should be dropped from the target's properties just before
the target's construct rule gets called.
I use it like this:
make foo.hpp
: $(sources)
: @make-foo
: <ignore-feature>variant
<ignore-feature>toolset
<ignore-feature>threading
;
actions make-foo
{
make-foo.sh $(>)
}
If a composite feature is ignored, then all component features of the
composite feature are ignored too.
Comments appreciated.
-- Jon Biggar Floorboard Software jon_at_[hidden] jon_at_[hidden]
==== tools/build/v2/build/property-set.jam#2 (text) ====
@@ -442,3 +442,25 @@
}
return $(.empty) ;
}
+
+rule remove-ignored ( orig-properties )
+{
+ local to-ignore = [ $(orig-properties).get <ignore-feature> ] ;
+
+ to-ignore = <$(to-ignore)> ;
+
+ local ignored ;
+ local props = [ $(orig-properties).raw ] ;
+
+ for local prop in $(props)
+ {
+ if $(prop:G) in $(to-ignore)
+ {
+ ignored += $(prop) ;
+ }
+ }
+
+ local to-remove = [ feature.expand $(ignored) ] ;
+
+ return [ property-set.create [ set.difference $(props) : $(to-remove) ] ] ;
+}
==== tools/build/v2/build/targets.jam#2 (text) ====
@@ -1189,6 +1189,8 @@
$(usage-requirements) ] ;
usage-requirements = [ property-set.create $(usage-requirements) ] ;
+ rproperties = [ property-set.remove-ignored $(rproperties) ] ;
+
if [ modules.peek : .debug-building ]
{
ECHO [ targets.indent ]
==== tools/build/v2/tools/builtin.jam#2 (text) ====
@@ -260,6 +260,10 @@
feature.feature variant : : implicit composite propagated symmetric ;
+# A meta-feature that tells the build system to ignore certain other features
+# when building a target
+
+feature.feature ignore-feature : : incidental free ;
# Declares a new variant.
#
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