From b67df40f139cfba4673c72519e3604243c068024 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 28 Jan 2003 15:20:23 +0000 Subject: [PATCH] Improve handling of features. Now they are composed only of explicitly specified properties. * new/builtin.jam: (variant): Don't add defaults. * new/feature.jam: (minimize): Eliminate defauls, when possible. [SVN r17066] --- new/builtin.jam | 16 ++--------- new/feature.jam | 68 +++++++++++++++++++++++++++++--------------- v2/build/feature.jam | 68 +++++++++++++++++++++++++++++--------------- v2/tools/builtin.jam | 16 ++--------- 4 files changed, 94 insertions(+), 74 deletions(-) diff --git a/new/builtin.jam b/new/builtin.jam index ce443f66b..c6870b97c 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -121,21 +121,9 @@ rule variant ( name # Name of the variant # We do this after inheriting parents' properties, so that # they affect other variants, derived from this one. .explicit-properties.$(name) = $(explicit-properties) ; - - local fool-properties = [ feature.add-defaults $(explicit-properties) ] ; - - # Eliminate all symmetric features. - local full-properties2 ; - for local p in $(fool-properties) - { - if ! symmetric in [ feature.attributes $(p:G) ] - { - full-properties2 += $(p) ; - } - } - + feature.extend variant : $(name) ; - feature.compose $(name) : $(full-properties2) ; + feature.compose $(name) : $(explicit-properties) ; } IMPORT $(__name__) : variant : : variant ; diff --git a/new/feature.jam b/new/feature.jam index ea1e3eaa5..50289b7ad 100644 --- a/new/feature.jam +++ b/new/feature.jam @@ -611,13 +611,16 @@ local rule in-features ( feature-set-var property ) # Given an expanded property set, eliminate all redundancy: properties # which are elements of other (composite) properties in the set will -# be eliminated, implicit properties will be expressed without feature +# be eliminated. Non-symmetric properties equal to default values will be +# eliminated, unless the override a value from some composite property. +# Implicit properties will be expressed without feature # grist, and sub-property values will be expressed as elements joined # to the corresponding main property. rule minimize ( properties * ) { # remove properties implied by composite features local x = $(properties) ; + local components ; for local p in $(properties) { if ! $(p:G) @@ -625,9 +628,10 @@ rule minimize ( properties * ) error minimize requires an expanded property set, but \"$(p)\" appears to be the value of an un-expanded implicit feature ; } + components += $($(p).components:G) ; x = [ set.difference $(x) : $($(p).components) ] ; } - + # handle subfeatures and implicit features local result ; while $(x) @@ -641,29 +645,43 @@ rule minimize ( properties * ) p = $(p:G="") ; } - # locate all subproperties of f in the property set - local subproperties ; - local subfeatures = $($(f).subfeatures) ; - if $(subfeatures) + # eliminate properties which value is equal to feature's default + # and which are not symmetric + if $(p) = [ defaults $(f) ] && ! symmetric in [ attributes $(f) ] + # If the feature is not specified in any of composite ones, + # then removing it is OK, because adding defaults would bring that + # feature back --- there's 1-1 correspondence between minimized + # and full property set. + && ! $(f:G) in $(components) { - local f_ = [ utility.ungrist $(f) ] ; - subfeatures = [ grist $(f_)-$(subfeatures) ] ; - subproperties = [ sequence.filter in-features subfeatures : $(x) ] ; - } - - if $(subproperties) - { - # reconstitute the joined property name - local sorted = [ sequence.insertion-sort $(subproperties) ] ; - result += $(p)-$(sorted:G="":J=-) ; - - x = [ set.difference $(x[2-]) : $(subproperties) ] ; - } - else - { - result += $(p) ; x = $(x[2-]) ; } + else + { + # locate all subproperties of f in the property set + local subproperties ; + local subfeatures = $($(f).subfeatures) ; + if $(subfeatures) + { + local f_ = [ utility.ungrist $(f) ] ; + subfeatures = [ grist $(f_)-$(subfeatures) ] ; + subproperties = [ sequence.filter in-features subfeatures : $(x) ] ; + } + + if $(subproperties) + { + # reconstitute the joined property name + local sorted = [ sequence.insertion-sort $(subproperties) ] ; + result += $(p)-$(sorted:G="":J=-) ; + + x = [ set.difference $(x[2-]) : $(subproperties) ] ; + } + else + { + result += $(p) ; + x = $(x[2-]) ; + } + } } return $(result) ; } @@ -866,9 +884,13 @@ local rule __test__ ( ) assert.result gcc-3.0.1 debug on - : minimize [ expand gcc-3.0.1 debug on ] + : minimize [ expand gcc-3.0.1 debug on native ] ; + assert.result gcc-3.0.1 debug dynamic + : minimize [ expand gcc-3.0.1 debug off dynamic ] + ; + assert.result gcc-3.0.1 debug : minimize [ expand gcc-3.0.1 debug off ] ; diff --git a/v2/build/feature.jam b/v2/build/feature.jam index ea1e3eaa5..50289b7ad 100644 --- a/v2/build/feature.jam +++ b/v2/build/feature.jam @@ -611,13 +611,16 @@ local rule in-features ( feature-set-var property ) # Given an expanded property set, eliminate all redundancy: properties # which are elements of other (composite) properties in the set will -# be eliminated, implicit properties will be expressed without feature +# be eliminated. Non-symmetric properties equal to default values will be +# eliminated, unless the override a value from some composite property. +# Implicit properties will be expressed without feature # grist, and sub-property values will be expressed as elements joined # to the corresponding main property. rule minimize ( properties * ) { # remove properties implied by composite features local x = $(properties) ; + local components ; for local p in $(properties) { if ! $(p:G) @@ -625,9 +628,10 @@ rule minimize ( properties * ) error minimize requires an expanded property set, but \"$(p)\" appears to be the value of an un-expanded implicit feature ; } + components += $($(p).components:G) ; x = [ set.difference $(x) : $($(p).components) ] ; } - + # handle subfeatures and implicit features local result ; while $(x) @@ -641,29 +645,43 @@ rule minimize ( properties * ) p = $(p:G="") ; } - # locate all subproperties of f in the property set - local subproperties ; - local subfeatures = $($(f).subfeatures) ; - if $(subfeatures) + # eliminate properties which value is equal to feature's default + # and which are not symmetric + if $(p) = [ defaults $(f) ] && ! symmetric in [ attributes $(f) ] + # If the feature is not specified in any of composite ones, + # then removing it is OK, because adding defaults would bring that + # feature back --- there's 1-1 correspondence between minimized + # and full property set. + && ! $(f:G) in $(components) { - local f_ = [ utility.ungrist $(f) ] ; - subfeatures = [ grist $(f_)-$(subfeatures) ] ; - subproperties = [ sequence.filter in-features subfeatures : $(x) ] ; - } - - if $(subproperties) - { - # reconstitute the joined property name - local sorted = [ sequence.insertion-sort $(subproperties) ] ; - result += $(p)-$(sorted:G="":J=-) ; - - x = [ set.difference $(x[2-]) : $(subproperties) ] ; - } - else - { - result += $(p) ; x = $(x[2-]) ; } + else + { + # locate all subproperties of f in the property set + local subproperties ; + local subfeatures = $($(f).subfeatures) ; + if $(subfeatures) + { + local f_ = [ utility.ungrist $(f) ] ; + subfeatures = [ grist $(f_)-$(subfeatures) ] ; + subproperties = [ sequence.filter in-features subfeatures : $(x) ] ; + } + + if $(subproperties) + { + # reconstitute the joined property name + local sorted = [ sequence.insertion-sort $(subproperties) ] ; + result += $(p)-$(sorted:G="":J=-) ; + + x = [ set.difference $(x[2-]) : $(subproperties) ] ; + } + else + { + result += $(p) ; + x = $(x[2-]) ; + } + } } return $(result) ; } @@ -866,9 +884,13 @@ local rule __test__ ( ) assert.result gcc-3.0.1 debug on - : minimize [ expand gcc-3.0.1 debug on ] + : minimize [ expand gcc-3.0.1 debug on native ] ; + assert.result gcc-3.0.1 debug dynamic + : minimize [ expand gcc-3.0.1 debug off dynamic ] + ; + assert.result gcc-3.0.1 debug : minimize [ expand gcc-3.0.1 debug off ] ; diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index ce443f66b..c6870b97c 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -121,21 +121,9 @@ rule variant ( name # Name of the variant # We do this after inheriting parents' properties, so that # they affect other variants, derived from this one. .explicit-properties.$(name) = $(explicit-properties) ; - - local fool-properties = [ feature.add-defaults $(explicit-properties) ] ; - - # Eliminate all symmetric features. - local full-properties2 ; - for local p in $(fool-properties) - { - if ! symmetric in [ feature.attributes $(p:G) ] - { - full-properties2 += $(p) ; - } - } - + feature.extend variant : $(name) ; - feature.compose $(name) : $(full-properties2) ; + feature.compose $(name) : $(explicit-properties) ; } IMPORT $(__name__) : variant : : variant ;