diff --git a/new/builtin.jam b/new/builtin.jam index 34b78ab0f..f90dfdc5f 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -65,8 +65,12 @@ rule compile-action ( targets + : sources * : action-name : properties * ) rule adjust-properties ( properties * ) { - ECHO "Gonna adjust includes for action " $(action) ; - return $(properties) ; + local dg = [ $(self.targets[1]).dg ] ; + local target-paths = [ $(dg).all-target-directories ] ; + # Note that target-paths here are already relative to invocation + # directory, and can be used as-is. + + return $(properties) $(target-paths:G=include) ; } } diff --git a/new/targets.jam b/new/targets.jam index d577d73cb..7764d2eef 100644 --- a/new/targets.jam +++ b/new/targets.jam @@ -214,8 +214,15 @@ rule main-target ( name : project ) local pr = [ property.take free : [ property.remove incidental : [ project.attribute $(self.project) requirements ] ] ] ; - for local v in $(result) + # 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 "FIXME" : "FIXME" : $(all-targets) ] ; + for local v in $(all-targets) { + $(v).dg $(dg) ; + local action = [ $(v).action ] ; if $(action) { diff --git a/new/virtual-target.jam b/new/virtual-target.jam index 2ba077fce..30c92ecaf 100644 --- a/new/virtual-target.jam +++ b/new/virtual-target.jam @@ -18,7 +18,7 @@ rule virtual-target ( name : type ? : project { self.name = $(name) ; self.type = $(type) ; - self.subvariant = $(subvariant) ; + self.subvariant = [ property.remove free incidental : $(subvariant) ] ; self.project = $(project) ; self.includes = ; @@ -70,12 +70,24 @@ rule virtual-target ( name : type ? : project # Returns the action currently set. rule action ( a ? ) { - if $(a) { + if $(a) + { self.action = $(a) ; } return $(self.action) ; } + # Sets the dependency graph this target is part of. + # 'dg' is an instance of 'subvariant-dg' class. + rule dg ( dg ? ) + { + if $(dg) + { + self.dg = $(dg) ; + } + return $(self.dg) ; + } + # Specified an extra element to be added to the target path. rule extra-path ( p ) { @@ -102,10 +114,7 @@ rule virtual-target ( name : type ? : project local a = [ action ] ; if $(a) { $(a).actualize ; - local path = [ path.join [ project.attribute $(self.project) location ] - "bin" [ property.as-path [ subvariant ] ] - $(self.extra-path) ] ; - path = [ path.native $(path) ] ; + local path = [ path ] ; LOCATE on $(self.actual-name) = $(path) ; DEPENDS $(self.actual-name) : $(path) ; common.MkDir $(path) ; @@ -189,6 +198,16 @@ rule virtual-target ( name : type ? : project } return $(self.actual-name) ; } + + # Returns the directory for this target + rule path ( ) + { + local path = [ path.join [ project.attribute $(self.project) location ] + "bin" [ property.as-path [ subvariant ] ] + $(self.extra-path) ] ; + return [ path.native $(path) ] ; + } + } class virtual-target ; @@ -249,7 +268,7 @@ rule action ( targets + : sources * : action-name : properties * ) DEPENDS $(actual-targets) : $(actual-sources) ; $(self.action-name) - $(actual-targets) : $(actual-sources) : [ properties ] ; + $(actual-targets) : $(actual-sources) : $(properties) ; } } @@ -259,7 +278,7 @@ rule action ( targets + : sources * : action-name : properties * ) # its argument. rule adjust-properties ( properties * ) { - return $(property) ; + return $(properties) ; } @@ -339,6 +358,26 @@ rule register ( target ) return $(result) ; } +# Traverses the dependency graph of 'target' and return all targets that will +# be created before this one is created. +rule traverse ( target ) +{ + local result ; + if [ $(target).action ] + { + local action = [ $(target).action ] ; + # This includes 'target' as well + result += [ $(action).targets ] ; + + for local t in [ $(action).sources ] + { + result += [ traverse $(t) ] ; + } + } + return $(result) ; +} + + # Clones a virtual target, copying all fields that can be set in ctor, setting # project of new targets to 'project'. # If 'dont-recurse' is not set, clones action as well, which causes cloning @@ -415,3 +454,23 @@ local rule clone-action-template ( action from cloned-from project name type suf return $(cloned) ; } + +local rule subvariant-dg ( main-target : properties * : virtual-targets * ) +{ + self.main-target = $(main-target) ; + self.properties = $(properties) ; + self.virtual-targets = $(virtual-targets) ; + + rule all-target-directories ( ) + { + local result ; + for local t in $(self.virtual-targets) + { + result = [ sequence.merge $(result) : [ $(t).path ] ] ; + } + return $(result) ; + } +} + +class subvariant-dg ; + diff --git a/test/dependency_test.py b/test/dependency_test.py new file mode 100644 index 000000000..54e86a884 --- /dev/null +++ b/test/dependency_test.py @@ -0,0 +1,12 @@ +#!/usr/bin/python + +from BoostBuild import Tester, List + +t = Tester() + +t.set_tree("dependency-test") +t.run_build_system() +# Do not bother checking for created files now. + + +t.cleanup() diff --git a/test/test_all.py b/test/test_all.py index 8bec314f4..19e34050d 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -19,3 +19,4 @@ import project_test1 import project_test3 import project_test4 import generators_test +import dependency_test diff --git a/v2/build/targets.jam b/v2/build/targets.jam index d577d73cb..7764d2eef 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -214,8 +214,15 @@ rule main-target ( name : project ) local pr = [ property.take free : [ property.remove incidental : [ project.attribute $(self.project) requirements ] ] ] ; - for local v in $(result) + # 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 "FIXME" : "FIXME" : $(all-targets) ] ; + for local v in $(all-targets) { + $(v).dg $(dg) ; + local action = [ $(v).action ] ; if $(action) { diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index 2ba077fce..30c92ecaf 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -18,7 +18,7 @@ rule virtual-target ( name : type ? : project { self.name = $(name) ; self.type = $(type) ; - self.subvariant = $(subvariant) ; + self.subvariant = [ property.remove free incidental : $(subvariant) ] ; self.project = $(project) ; self.includes = ; @@ -70,12 +70,24 @@ rule virtual-target ( name : type ? : project # Returns the action currently set. rule action ( a ? ) { - if $(a) { + if $(a) + { self.action = $(a) ; } return $(self.action) ; } + # Sets the dependency graph this target is part of. + # 'dg' is an instance of 'subvariant-dg' class. + rule dg ( dg ? ) + { + if $(dg) + { + self.dg = $(dg) ; + } + return $(self.dg) ; + } + # Specified an extra element to be added to the target path. rule extra-path ( p ) { @@ -102,10 +114,7 @@ rule virtual-target ( name : type ? : project local a = [ action ] ; if $(a) { $(a).actualize ; - local path = [ path.join [ project.attribute $(self.project) location ] - "bin" [ property.as-path [ subvariant ] ] - $(self.extra-path) ] ; - path = [ path.native $(path) ] ; + local path = [ path ] ; LOCATE on $(self.actual-name) = $(path) ; DEPENDS $(self.actual-name) : $(path) ; common.MkDir $(path) ; @@ -189,6 +198,16 @@ rule virtual-target ( name : type ? : project } return $(self.actual-name) ; } + + # Returns the directory for this target + rule path ( ) + { + local path = [ path.join [ project.attribute $(self.project) location ] + "bin" [ property.as-path [ subvariant ] ] + $(self.extra-path) ] ; + return [ path.native $(path) ] ; + } + } class virtual-target ; @@ -249,7 +268,7 @@ rule action ( targets + : sources * : action-name : properties * ) DEPENDS $(actual-targets) : $(actual-sources) ; $(self.action-name) - $(actual-targets) : $(actual-sources) : [ properties ] ; + $(actual-targets) : $(actual-sources) : $(properties) ; } } @@ -259,7 +278,7 @@ rule action ( targets + : sources * : action-name : properties * ) # its argument. rule adjust-properties ( properties * ) { - return $(property) ; + return $(properties) ; } @@ -339,6 +358,26 @@ rule register ( target ) return $(result) ; } +# Traverses the dependency graph of 'target' and return all targets that will +# be created before this one is created. +rule traverse ( target ) +{ + local result ; + if [ $(target).action ] + { + local action = [ $(target).action ] ; + # This includes 'target' as well + result += [ $(action).targets ] ; + + for local t in [ $(action).sources ] + { + result += [ traverse $(t) ] ; + } + } + return $(result) ; +} + + # Clones a virtual target, copying all fields that can be set in ctor, setting # project of new targets to 'project'. # If 'dont-recurse' is not set, clones action as well, which causes cloning @@ -415,3 +454,23 @@ local rule clone-action-template ( action from cloned-from project name type suf return $(cloned) ; } + +local rule subvariant-dg ( main-target : properties * : virtual-targets * ) +{ + self.main-target = $(main-target) ; + self.properties = $(properties) ; + self.virtual-targets = $(virtual-targets) ; + + rule all-target-directories ( ) + { + local result ; + for local t in $(self.virtual-targets) + { + result = [ sequence.merge $(result) : [ $(t).path ] ] ; + } + return $(result) ; + } +} + +class subvariant-dg ; + diff --git a/v2/test/dependency_test.py b/v2/test/dependency_test.py new file mode 100644 index 000000000..54e86a884 --- /dev/null +++ b/v2/test/dependency_test.py @@ -0,0 +1,12 @@ +#!/usr/bin/python + +from BoostBuild import Tester, List + +t = Tester() + +t.set_tree("dependency-test") +t.run_build_system() +# Do not bother checking for created files now. + + +t.cleanup() diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 8bec314f4..19e34050d 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -19,3 +19,4 @@ import project_test1 import project_test3 import project_test4 import generators_test +import dependency_test diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 34b78ab0f..f90dfdc5f 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -65,8 +65,12 @@ rule compile-action ( targets + : sources * : action-name : properties * ) rule adjust-properties ( properties * ) { - ECHO "Gonna adjust includes for action " $(action) ; - return $(properties) ; + local dg = [ $(self.targets[1]).dg ] ; + local target-paths = [ $(dg).all-target-directories ] ; + # Note that target-paths here are already relative to invocation + # directory, and can be used as-is. + + return $(properties) $(target-paths:G=include) ; } }