diff --git a/new/builtin.jam b/new/builtin.jam index 60cf2c87b..6bb78a1a2 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -575,6 +575,30 @@ rule linking-generator ( id composing ? : source-types + : target-types + : composing ?= true ; generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : $(requirements) ; + + rule run ( project name ? : property-set : sources + : multiple ? ) + { + local result = [ generator.run $(project) $(name) : $(property-set) + : $(sources) : $(multiple) ] ; + + if $(result) + { + # Explicitly set dependency on all features. + + local libs = [ feature.get-values : + [ $(property-set).raw ] ] ; + + if $(libs) + { + for local t in $(result) + { + $(t).depends $(libs:G=) ; + } + } + } + return $(result) ; + } + rule action-class ( ) { diff --git a/new/generators.jam b/new/generators.jam index 7f406fbb3..0009bd0ca 100644 --- a/new/generators.jam +++ b/new/generators.jam @@ -907,17 +907,10 @@ local rule construct-without-caching ( # targets. rule construct ( project name ? : target-type multiple ? : property-set * : sources * ) { - local usage-requirements ; if (.construct-stack) { ensure-type $(sources) ; - for local e in $(sources) - { - usage-requirements += [ $(e).usage-requirements ] ; - } } - property-set = [ $(property-set).add - [ property-set.create $(usage-requirements) ] ] ; .construct-stack += 1 ; @@ -950,17 +943,6 @@ rule construct ( project name ? : target-type multiple ? : property-set * : sour if ! $(.construct-stack) # This is first invocation in stack { - # Make roots of dependency graph depend on all 'dependency' features. - local dp = [ $(property-set).dependency ] ; - - if $(dp) - { - for local t in $(result) - { - $(t).depends $(dp:G=) ; - } - } - local result2 ; for local t in $(result) { diff --git a/new/targets.jam b/new/targets.jam index 87d5e76c1..80b16c7f3 100644 --- a/new/targets.jam +++ b/new/targets.jam @@ -384,23 +384,7 @@ rule main-target ( name : project ) else { local result = [ $(best-alternatives).generate $(property-set) ] ; - - # Mark all targets in result as roots - for local t in $(result) - { - $(t).root true ; - } - - # Process all vtargets that will be created if this main target - # is created. - local all-targets = - [ sequence.transform virtual-target.traverse : $(result) ] ; - local dg = [ new subvariant-dg $(__name__) : $(property-set) : $(all-targets) ] ; - for local v in $(all-targets) - { - $(v).dg $(dg) ; - } - + # Now return virtual targets for the only alternative return $(result) ; } @@ -607,10 +591,20 @@ rule basic-target ( name : project { local source-targets = [ generate-sources $(rproperties) ] ; - self.generated.$(property-set) = + # Grab usage requirements from source targets + local usage-requirements ; + for local e in $(source-targets) + { + usage-requirements += [ $(e).usage-requirements ] ; + } + rproperties = [ $(rproperties).add + [ property-set.create $(usage-requirements) ] ] ; + + + local result = [ construct $(source-targets) : $(rproperties) ] ; check-for-unused-sources - $(self.generated.$(property-set)) : $(source-targets) ; + $(result) : $(source-targets) ; # Apply use requirement of this target to all generated # virtual targets. @@ -620,10 +614,24 @@ rule basic-target ( name : project : $(self.project) : $(rproperties) ] ; xusage-requirements = [ $(xusage-requirements).raw ] ; - for local e in $(self.generated.$(property-set)) + for local e in $(result) { $(e).set-usage-requirements $(xusage-requirements) ; + $(e).root true ; } + + # Process all vtargets that will be created if this main target + # is created. + local all-targets = + [ sequence.transform virtual-target.traverse : $(result) ] ; + local dg = [ new subvariant-dg $(__name__) : $(property-set) + : $(rproperties) : $(all-targets) ] ; + for local v in $(all-targets) + { + $(v).dg $(dg) ; + } + + self.generated.$(property-set) = $(result) ; } else { diff --git a/new/virtual-target.jam b/new/virtual-target.jam index caea8ef02..f9637b08e 100644 --- a/new/virtual-target.jam +++ b/new/virtual-target.jam @@ -865,20 +865,24 @@ local rule clone-action-template ( action from cloned-from : new-source ) local rule subvariant-dg ( main-target # The instance of main-target class : property-set # Properties requested for this target + : actual-properties # Actual used properties : virtual-targets * ) { self.main-target = $(main-target) ; self.properties = $(property-set) ; + self.actual-properties = $(actual-properties) ; self.virtual-targets = $(virtual-targets) ; # Pre-compose the list of other dependency graphs, on which this one # depends + local deps = [ $(actual-properties).dependency ] ; + for local d in $(deps) + { + self.other-dg += [ $(d:G=).dg ] ; + } + for local t in $(virtual-targets) { - for local d in [ $(t).dependencies ] - { - self.other-dg += [ $(d).dg ] ; - } local a = [ $(t).action ] ; if $(a) { @@ -891,8 +895,9 @@ local rule subvariant-dg ( main-target # The instance of main-target class } } } + self.other-dg = [ sequence.unique $(self.other-dg) ] ; - + rule main-target ( ) { return $(self.main-target) ; diff --git a/test/dependency_test.py b/test/dependency_test.py index 1a240bf6a..0068d3423 100644 --- a/test/dependency_test.py +++ b/test/dependency_test.py @@ -22,7 +22,10 @@ t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") t.expect_touch("bin/$toolset/debug/b.exe") t.expect_touch("bin/$toolset/debug/b.obj") -t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") +# Now, does not add dependency. +# It sound weird, but is intentional. Need +# to rename eventually. +#t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.expect_nothing_more() # Only 'a' include and should be updated @@ -31,7 +34,6 @@ t.run_build_system() t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") -t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.expect_nothing_more() # "src/a.h" includes "b.h" (in the same dir) @@ -39,7 +41,6 @@ t.touch("src1/b.h") t.run_build_system() t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") -t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.expect_nothing_more() # included by "src/b.h". We had a bug: file included via "", diff --git a/v2/build/generators.jam b/v2/build/generators.jam index 7f406fbb3..0009bd0ca 100644 --- a/v2/build/generators.jam +++ b/v2/build/generators.jam @@ -907,17 +907,10 @@ local rule construct-without-caching ( # targets. rule construct ( project name ? : target-type multiple ? : property-set * : sources * ) { - local usage-requirements ; if (.construct-stack) { ensure-type $(sources) ; - for local e in $(sources) - { - usage-requirements += [ $(e).usage-requirements ] ; - } } - property-set = [ $(property-set).add - [ property-set.create $(usage-requirements) ] ] ; .construct-stack += 1 ; @@ -950,17 +943,6 @@ rule construct ( project name ? : target-type multiple ? : property-set * : sour if ! $(.construct-stack) # This is first invocation in stack { - # Make roots of dependency graph depend on all 'dependency' features. - local dp = [ $(property-set).dependency ] ; - - if $(dp) - { - for local t in $(result) - { - $(t).depends $(dp:G=) ; - } - } - local result2 ; for local t in $(result) { diff --git a/v2/build/targets.jam b/v2/build/targets.jam index 87d5e76c1..80b16c7f3 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -384,23 +384,7 @@ rule main-target ( name : project ) else { local result = [ $(best-alternatives).generate $(property-set) ] ; - - # Mark all targets in result as roots - for local t in $(result) - { - $(t).root true ; - } - - # Process all vtargets that will be created if this main target - # is created. - local all-targets = - [ sequence.transform virtual-target.traverse : $(result) ] ; - local dg = [ new subvariant-dg $(__name__) : $(property-set) : $(all-targets) ] ; - for local v in $(all-targets) - { - $(v).dg $(dg) ; - } - + # Now return virtual targets for the only alternative return $(result) ; } @@ -607,10 +591,20 @@ rule basic-target ( name : project { local source-targets = [ generate-sources $(rproperties) ] ; - self.generated.$(property-set) = + # Grab usage requirements from source targets + local usage-requirements ; + for local e in $(source-targets) + { + usage-requirements += [ $(e).usage-requirements ] ; + } + rproperties = [ $(rproperties).add + [ property-set.create $(usage-requirements) ] ] ; + + + local result = [ construct $(source-targets) : $(rproperties) ] ; check-for-unused-sources - $(self.generated.$(property-set)) : $(source-targets) ; + $(result) : $(source-targets) ; # Apply use requirement of this target to all generated # virtual targets. @@ -620,10 +614,24 @@ rule basic-target ( name : project : $(self.project) : $(rproperties) ] ; xusage-requirements = [ $(xusage-requirements).raw ] ; - for local e in $(self.generated.$(property-set)) + for local e in $(result) { $(e).set-usage-requirements $(xusage-requirements) ; + $(e).root true ; } + + # Process all vtargets that will be created if this main target + # is created. + local all-targets = + [ sequence.transform virtual-target.traverse : $(result) ] ; + local dg = [ new subvariant-dg $(__name__) : $(property-set) + : $(rproperties) : $(all-targets) ] ; + for local v in $(all-targets) + { + $(v).dg $(dg) ; + } + + self.generated.$(property-set) = $(result) ; } else { diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index caea8ef02..f9637b08e 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -865,20 +865,24 @@ local rule clone-action-template ( action from cloned-from : new-source ) local rule subvariant-dg ( main-target # The instance of main-target class : property-set # Properties requested for this target + : actual-properties # Actual used properties : virtual-targets * ) { self.main-target = $(main-target) ; self.properties = $(property-set) ; + self.actual-properties = $(actual-properties) ; self.virtual-targets = $(virtual-targets) ; # Pre-compose the list of other dependency graphs, on which this one # depends + local deps = [ $(actual-properties).dependency ] ; + for local d in $(deps) + { + self.other-dg += [ $(d:G=).dg ] ; + } + for local t in $(virtual-targets) { - for local d in [ $(t).dependencies ] - { - self.other-dg += [ $(d).dg ] ; - } local a = [ $(t).action ] ; if $(a) { @@ -891,8 +895,9 @@ local rule subvariant-dg ( main-target # The instance of main-target class } } } + self.other-dg = [ sequence.unique $(self.other-dg) ] ; - + rule main-target ( ) { return $(self.main-target) ; diff --git a/v2/test/dependency_test.py b/v2/test/dependency_test.py index 1a240bf6a..0068d3423 100644 --- a/v2/test/dependency_test.py +++ b/v2/test/dependency_test.py @@ -22,7 +22,10 @@ t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") t.expect_touch("bin/$toolset/debug/b.exe") t.expect_touch("bin/$toolset/debug/b.obj") -t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") +# Now, does not add dependency. +# It sound weird, but is intentional. Need +# to rename eventually. +#t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.expect_nothing_more() # Only 'a' include and should be updated @@ -31,7 +34,6 @@ t.run_build_system() t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") -t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.expect_nothing_more() # "src/a.h" includes "b.h" (in the same dir) @@ -39,7 +41,6 @@ t.touch("src1/b.h") t.run_build_system() t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") -t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.expect_nothing_more() # included by "src/b.h". We had a bug: file included via "", diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 60cf2c87b..6bb78a1a2 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -575,6 +575,30 @@ rule linking-generator ( id composing ? : source-types + : target-types + : composing ?= true ; generator.__init__ $(id) $(composing) : $(source-types) : $(target-types) : $(requirements) ; + + rule run ( project name ? : property-set : sources + : multiple ? ) + { + local result = [ generator.run $(project) $(name) : $(property-set) + : $(sources) : $(multiple) ] ; + + if $(result) + { + # Explicitly set dependency on all features. + + local libs = [ feature.get-values : + [ $(property-set).raw ] ] ; + + if $(libs) + { + for local t in $(result) + { + $(t).depends $(libs:G=) ; + } + } + } + return $(result) ; + } + rule action-class ( ) {