From 47c9cd43fc55f07cb80cf943871eec22177f8281 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 11 Apr 2009 07:22:28 +0000 Subject: [PATCH] Improve handling of 'complete' build type. Previous code used default-build attribute to cause a number of property sets be requested, and then used indirect conditional requirements to filter out inappropriate ones, using the no feature. This worked but is messy, and resulted in a pile of unclear messages about no. This patch introduces custom main target class that handles filtering, so we don't ever try to build with undesired property sets. [SVN r52319] --- src/build/targets.jam | 143 ++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 60 deletions(-) diff --git a/src/build/targets.jam b/src/build/targets.jam index 20da57988..a7aa2c008 100644 --- a/src/build/targets.jam +++ b/src/build/targets.jam @@ -78,6 +78,7 @@ import property-set ; import sequence ; import set ; import toolset ; +import build-request ; # Base class for all abstract targets. @@ -557,7 +558,6 @@ local rule end-building ( main-target-instance ) class main-target : abstract-target { import assert ; - import build-request ; import errors ; import feature ; import print ; @@ -657,65 +657,8 @@ class main-target : abstract-target rule apply-default-build ( property-set ) { - # 1. First, see what properties from default-build are already present - # in property-set. - - local raw = [ $(property-set).raw ] ; - local specified-features = $(raw:G) ; - - local defaults-to-apply ; - for local d in [ $(self.default-build).raw ] - { - if ! $(d:G) in $(specified-features) - { - defaults-to-apply += $(d) ; - } - } - - # 2. If there are any defaults to be applied, form a new build request. - # Pass it through to 'expand-no-defaults' since default-build might - # contain "release debug" resulting in two property-sets. - local result ; - if $(defaults-to-apply) - { - properties = [ - build-request.expand-no-defaults - - # We have to compress subproperties here to prevent property - # lists like: - # - # msvc 7.1 multi - # - # from being expanded into: - # - # 7.1/multi - # msvc/7.1/multi - # - # due to a cross-product property combination. That may be an - # indication that build-request.expand-no-defaults is the wrong - # rule to use here. - [ feature.compress-subproperties $(raw) ] - $(defaults-to-apply) - ] ; - - if $(properties) - { - for local p in $(properties) - { - result += [ property-set.create - [ feature.expand [ feature.split $(p) ] ] ] ; - } - } - else - { - result = [ property-set.empty ] ; - } - } - else - { - result = $(property-set) ; - } - return $(result) ; + return [ targets.apply-default-build $(property-set) + : $(self.default-build) ] ; } # Select an alternative for this main target, by finding all alternatives @@ -883,6 +826,69 @@ rule generate-from-reference ( return [ $(target).generate $(rproperties) ] ; } +rule apply-default-build ( property-set : default-build ) +{ + # 1. First, see what properties from default-build are already present + # in property-set. + + local raw = [ $(property-set).raw ] ; + local specified-features = $(raw:G) ; + + local defaults-to-apply ; + for local d in [ $(default-build).raw ] + { + if ! $(d:G) in $(specified-features) + { + defaults-to-apply += $(d) ; + } + } + + # 2. If there are any defaults to be applied, form a new build request. + # Pass it through to 'expand-no-defaults' since default-build might + # contain "release debug" resulting in two property-sets. + local result ; + if $(defaults-to-apply) + { + properties = [ + build-request.expand-no-defaults + + # We have to compress subproperties here to prevent property + # lists like: + # + # msvc 7.1 multi + # + # from being expanded into: + # + # 7.1/multi + # msvc/7.1/multi + # + # due to a cross-product property combination. That may be an + # indication that build-request.expand-no-defaults is the wrong + # rule to use here. + [ feature.compress-subproperties $(raw) ] + $(defaults-to-apply) + ] ; + + if $(properties) + { + for local p in $(properties) + { + result += [ property-set.create + [ feature.expand [ feature.split $(p) ] ] ] ; + } + } + else + { + result = [ property-set.empty ] ; + } + } + else + { + result = $(property-set) ; + } + return $(result) ; +} + # Given a build request and requirements, return properties common to dependency # build request and target requirements. @@ -1559,6 +1565,23 @@ rule main-target-alternative ( target ) return $(target) ; } +# Creates a new metargets with the specified properties, using 'klass' as +# the class. The 'name', 'sources', +# 'requirements', 'default-build' and 'usage-requirements' are assumed to be in +# the form specified by the user in Jamfile corresponding to 'project'. +# +rule create-metatarget ( klass : project : name : sources * : requirements * : + default-build * : usage-requirements * ) +{ + return [ + targets.main-target-alternative + [ new $(klass) $(name) : $(project) + : [ targets.main-target-sources $(sources) : $(name) ] + : [ targets.main-target-requirements $(requirements) : $(project) ] + : [ targets.main-target-default-build $(default-build) : $(project) ] + : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ] + ] ] ; +} # Creates a typed-target with the specified properties. The 'name', 'sources', # 'requirements', 'default-build' and 'usage-requirements' are assumed to be in