From dbaeb3aa93e350a377e71cc2435fc9efdd177b61 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 28 Nov 2002 09:14:41 +0000 Subject: [PATCH] Make file-target decide is main target name should be present in target path, instead of doing this high in control structure. * new/targets.jam (main-target.generate): Don't bother with setting extra path on generated targets. * new/virtual-target.jam (virtual-target.extra-path): Remove. (virtual-target.compute-extra-path): New method. (subvariant): Document better. [SVN r16454] --- src/build/targets.jam | 38 ++++++++-------------------- src/build/virtual-target.jam | 49 ++++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/src/build/targets.jam b/src/build/targets.jam index c881648b1..e03b39bd8 100644 --- a/src/build/targets.jam +++ b/src/build/targets.jam @@ -177,9 +177,9 @@ rule project-target ( name : project : requirements * : default-build * ) } } - # Returns the properties which would be used to a main + # Returns the properties which would be used for a main # target in this project, if generation with - # 'properties' is requested, and that main targets + # 'properties' is requested, and that main target # does not have any requirements of its own. rule reference-properties ( properties * ) { @@ -187,9 +187,7 @@ rule project-target ( name : project : requirements * : default-build * ) # from direct build request, because free properties are not # allowed to be propagated. - # ### Don't know why we stick 'properties' at the end of 'ref' - local ref = [ project.attribute $(self.project) requirements ] - $(properties) ; + local ref = [ project.attribute $(self.project) requirements ] ; ref = [ property.refine $(properties) : $(ref) ] ; ref = [ property.evaluate-conditionals $(ref) ] ; ref = [ property.take free : [ property.remove incidental : $(ref) ] ] ; @@ -300,14 +298,6 @@ rule main-target ( name : project ) error "Ambiguous alternatives for main target" [ full-name ] ; } } - - # Add additional subvariant element for the targets which free, - # non-incidental properties are not equal to project's, plus - # those in build request - - local plocation = [ project.attribute $(self.project) location ] ; - local ptarget = [ project.target $(plocation) ] ; - local ref = [ $(ptarget).reference-properties $(properties) ] ; # Mark all targets in result as roots for local t in $(result) @@ -319,22 +309,10 @@ rule main-target ( name : project ) # is created. local all-targets = [ sequence.transform virtual-target.traverse : $(result) ] ; - local dg = [ new subvariant-dg "FIXME" : "FIXME" : $(all-targets) ] ; + local dg = [ new subvariant-dg $(__name__) : $(properties) : $(all-targets) ] ; for local v in $(all-targets) { - $(v).dg $(dg) ; - - local action = [ $(v).action ] ; - if $(action) - { - local properties = [ property.take free : [ property.remove incidental : - [ $(action).properties ] ] ] ; - - if $(properties) != $(ref) - { - $(v).extra-path [ sequence.join main-target- $(self.name) ] ; - } - } + $(v).dg $(dg) ; } # Now return virtual targets for the only alternative @@ -500,9 +478,13 @@ rule basic-target ( name : project # Just a source file source-targets += [ virtual-target.from-file $(s) : $(self.project) ] ; } - } + } + self.generated.$(property-path) = [ construct $(source-targets) : $(xproperties) ] ; + + # Apply use requirement of this target to all generated + # virtual targets. local xuse-requirements ; for local p in $(self.use-requirements) { diff --git a/src/build/virtual-target.jam b/src/build/virtual-target.jam index 5a3bff174..9e3e00ffd 100644 --- a/src/build/virtual-target.jam +++ b/src/build/virtual-target.jam @@ -149,8 +149,9 @@ class virtual-target ; # The file path is determined as # - value passed to the 'set-path' method, if any # - for derived files, project's build dir, joined with components -# that describe action's properties, joined with the value -# passed to 'extra-path' method, if any, +# that describe action's properties. If the free properties +# are not equal to the project's reference properties +# an element with name of main target is added. # - for source files, project's source dir # # The file suffix is @@ -236,12 +237,6 @@ rule file-target ( name return $(self.dg) ; } - # Specified an extra element to be added to the target path. - rule extra-path ( p ) - { - self.extra-path = $(p) ; - } - # Specifies an extra grist to be added to the target name. rule extra-grist ( g ) { @@ -266,6 +261,7 @@ rule file-target ( name rule actualize-location ( target ) { + compute-extra-path ; if $(self.path) { LOCATE on $(target) = $(self.path) ; @@ -387,6 +383,7 @@ rule file-target ( name # which needs it. Will clean it up when cleaning subvariant. rule path ( ) { + compute-extra-path ; if $(self.path) { return $(self.path) ; @@ -402,6 +399,27 @@ rule file-target ( name return [ path.native $(path) ] ; } } + + rule compute-extra-path ( ) + { + if $(self.action) + { + local properties = [ property.take free : [ property.remove incidental : + [ $(self.action).properties ] ] ] ; + + local main-target = [ $(self.dg).main-target ] ; + local project = [ $(main-target).project ] ; + local plocation = [ project.attribute $(project) location ] ; + local ptarget = [ project.target $(plocation) ] ; + local ref = [ $(ptarget).reference-properties [ $(self.dg).properties ] ] ; + + if $(properties) != $(ref) + { + self.extra-path = [ sequence.join main-target- [ $(main-target).name ] ] ; + } + } + } + } class file-target : virtual-target ; @@ -700,7 +718,9 @@ local rule clone-action-template ( action from cloned-from : new-source ) return $(cloned) ; } -local rule subvariant-dg ( main-target : properties * : virtual-targets * ) +local rule subvariant-dg ( main-target # The instance of main-target class + : properties * # Properties requested for this target + : virtual-targets * ) { self.main-target = $(main-target) ; self.properties = $(properties) ; @@ -727,8 +747,17 @@ local rule subvariant-dg ( main-target : properties * : virtual-targets * ) } } self.other-dg = [ sequence.unique $(self.other-dg) ] ; - + rule main-target ( ) + { + return $(self.main-target) ; + } + + rule properties ( ) + { + return $(self.properties) ; + } + rule all-target-directories ( ) { local result ;