diff --git a/new/alias.jam b/new/alias.jam index 587b019c0..b4cb60e60 100644 --- a/new/alias.jam +++ b/new/alias.jam @@ -24,32 +24,33 @@ # import targets ; -import class : class new ; +import class : class new xnew ; import property ; import errors : error ; import type : type ; import regex ; -rule alias-target-class ( name : project : sources * : requirements * : default-build * ) +xclass alias-target-class : basic-target { - basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) - : $(default-build) ; - + rule __init__ ( name : project : sources * : requirements * : default-build * ) + { + basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) + : $(default-build) ; + } + rule construct ( source-targets * : property-set ) { return $(source-targets) ; } } -class alias-target-class : basic-target ; - # Declares the 'alias' target. It will build sources, and return them unaltered. rule alias ( name : sources * : requirements * : default-build * ) { local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new alias-target-class $(name) : $(project) + [ xnew alias-target-class $(name) : $(project) : [ targets.main-target-sources $(sources) : $(name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] diff --git a/new/builtin.jam b/new/builtin.jam index 947f18ca7..d0884d215 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -379,14 +379,17 @@ type.set-scanner CPP : c-scanner ; type.register H : h hpp ; type.register C : c ; -rule lib-target-class ( name : project - : sources * : requirements * : default-build * : usage-requirements * ) -{ - basic-target.__init__ $(name) : $(project) - : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; +xclass lib-target-class : basic-target +{ + import generators : construct : generators.construct ; - import generators : construct : generators.construct ; - + rule __init__ ( name : project + : sources * : requirements * : default-build * : usage-requirements * ) + { + basic-target.__init__ $(name) : $(project) + : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; + } + rule construct ( source-targets * : property-set ) { local properties = [ $(property-set).raw ] ; @@ -423,7 +426,6 @@ rule lib-target-class ( name : project } } -class lib-target-class : basic-target ; rule lib ( name : sources * : requirements * : default-build * : usage-requirements * ) @@ -433,7 +435,7 @@ rule lib ( name : sources * : requirements * : default-build * # This is a circular module dependency, so it must be imported here import targets ; targets.main-target-alternative - [ new lib-target-class $(name) : $(project) + [ xnew lib-target-class $(name) : $(project) : [ targets.main-target-sources $(sources) : $(name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] diff --git a/new/make.jam b/new/make.jam index 7b36e7856..9e7b988ec 100644 --- a/new/make.jam +++ b/new/make.jam @@ -13,16 +13,20 @@ import type : type ; import regex ; import property-set ; -rule make-target-class ( name : project : sources * : requirements * - : make-rule + : default-build * ) +xclass make-target-class : basic-target { - import type regex virtual-target ; + import type regex virtual-target ; + import class : xnew ; - basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) - : $(default-build) ; + rule __init__ ( name : project : sources * : requirements * + : make-rule + : default-build * ) + { + basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) + : $(default-build) ; - self.make-rule = $(make-rule) ; - + self.make-rule = $(make-rule) ; + } + rule construct ( source-targets * : property-set ) { local t = [ xnew file-target $(self.name:S=) : [ type.type $(self.name:S) ] @@ -34,7 +38,6 @@ rule make-target-class ( name : project : sources * : requirements * return [ virtual-target.register $(t) ] ; } } -class make-target-class : basic-target ; # Declares the 'make' main target. rule make ( target-name : sources * : generating-rule + : requirements * @@ -51,7 +54,7 @@ rule make ( target-name : sources * : generating-rule + : requirements * } targets.main-target-alternative - [ new make-target-class $(target-name) : $(caller) + [ xnew make-target-class $(target-name) : $(caller) : [ targets.main-target-sources $(sources) : $(target-name) ] : [ targets.main-target-requirements $(requirements) : $(caller) ] : $(generating-rule) diff --git a/new/project.jam b/new/project.jam index 03fccc2c5..74af9a763 100644 --- a/new/project.jam +++ b/new/project.jam @@ -44,7 +44,7 @@ import errors : error ; import project-roots ; import print ; -import class : class new ; +import class : class new xnew ; import errors ; import assert ; import property-set ; @@ -524,7 +524,7 @@ rule target ( project-module ) { if ! $(.target.$(project-module)) { - .target.$(project-module) = [ new project-target $(project-module) + .target.$(project-module) = [ xnew project-target $(project-module) : $(project-module) : [ attribute $(project-module) requirements ] ] ; } diff --git a/new/stage.jam b/new/stage.jam index 2e2434dee..51a2fefb1 100644 --- a/new/stage.jam +++ b/new/stage.jam @@ -36,13 +36,17 @@ import type ; import regex ; import generators ; -rule stage-target-class ( name-and-dir : project : sources * : requirements * : default-build * ) +xclass stage-target-class : basic-target { - basic-target.__init__ $(name-and-dir) : $(project) : $(sources) : $(requirements) - : $(default-build) ; - - import feature project type errors generators ; + import feature project type errors generators ; + import class : xnew ; + rule __init__ ( name-and-dir : project : sources * : requirements * : default-build * ) + { + basic-target.__init__ $(name-and-dir) : $(project) : $(sources) : $(requirements) + : $(default-build) ; + } + rule construct ( source-targets * : property-set ) { local name = [ $(property-set).get ] ; @@ -107,8 +111,6 @@ rule stage-target-class ( name-and-dir : project : sources * : requirements * : } -class stage-target-class : basic-target ; - # Declare staged version of the EXE type. Generator for this type will # cause relinking to the new location. type.register STAGED_EXE : : EXE ; @@ -168,7 +170,7 @@ rule stage ( name : sources * : requirements * : default-build * ) local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new stage-target-class $(name) : $(project) : $(sources) + [ xnew stage-target-class $(name) : $(project) : $(sources) : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ; diff --git a/new/symlink.jam b/new/symlink.jam index 89bcc6ef6..66f997ce2 100644 --- a/new/symlink.jam +++ b/new/symlink.jam @@ -14,39 +14,42 @@ feature.feature symlink-location : project-relative build-relative : incidental # The class representing "symlink" targets. # -rule symlink-targets ( - project - : targets * - : sources * - ) +xclass symlink-targets : basic-target { import numbers modules class property project ; - # Generate a fake name for now. Need unnamed targets eventually. - local c = [ modules.peek symlink : .count ] ; - modules.poke symlink : .count : [ numbers.increment $(c) ] ; - local fake-name = symlink#$(c) ; + rule __init__ ( + project + : targets * + : sources * + ) + { + # Generate a fake name for now. Need unnamed targets eventually. + local c = [ modules.peek symlink : .count ] ; + modules.poke symlink : .count : [ numbers.increment $(c) ] ; + local fake-name = symlink#$(c) ; - basic-target.__init__ $(fake-name) : $(project) : $(sources) ; + basic-target.__init__ $(fake-name) : $(project) : $(sources) ; - # Remember the targets to map the sources onto. Pad or truncate - # to fit the sources given. - self.targets = ; - for local source in $(sources) - { - if $(targets) + # Remember the targets to map the sources onto. Pad or truncate + # to fit the sources given. + self.targets = ; + for local source in $(sources) { - self.targets += $(targets[1]) ; - targets = $(targets[2-]) ; + if $(targets) + { + self.targets += $(targets[1]) ; + targets = $(targets[2-]) ; + } + else + { + self.targets += $(source) ; + } } - else - { - self.targets += $(source) ; - } - } - # The virtual targets corresponding to the given targets. - self.virtual-targets = ; + # The virtual targets corresponding to the given targets. + self.virtual-targets = ; + } rule construct ( source-targets * : property-set ) { @@ -71,7 +74,6 @@ rule symlink-targets ( return $(self.virtual-targets) ; } } -class.class symlink-targets : basic-target ; # Creates a symbolic link from a set of targets to a set of sources. # The targets and sources map one to one. The symlinks generated are @@ -95,7 +97,7 @@ rule symlink ( local project = [ CALLER_MODULE ] ; return [ targets.main-target-alternative - [ class.new symlink-targets $(project) : $(targets) : + [ class.xnew symlink-targets $(project) : $(targets) : # Note: inline targets are not supported for symlink, intentionally, # since it's used to linking existing non-local targets. $(sources) ] ] ; diff --git a/new/targets.jam b/new/targets.jam index ec681f0a2..c591d695d 100644 --- a/new/targets.jam +++ b/new/targets.jam @@ -80,19 +80,22 @@ import path ; import set ; # Base class for all abstract targets. -rule abstract-target ( name # name of the target in Jamfile - : project # the project module where the target is declared - ) +xclass abstract-target { - import project ; + import project ; - # Note: it might seem that we don't need either name or project at all. - # However, there are places where we really need it. One example is error - # messages which should name problematic targets. Another is setting correct - # paths for sources and generated files. - - self.name = $(name) ; - self.project = $(project) ; + rule __init__ ( name # name of the target in Jamfile + : project # the project module where the target is declared + ) + { + # Note: it might seem that we don't need either name or project at all. + # However, there are places where we really need it. One example is error + # messages which should name problematic targets. Another is setting correct + # paths for sources and generated files. + + self.name = $(name) ; + self.project = $(project) ; + } # Returns the name of this target. rule name ( ) @@ -144,7 +147,6 @@ rule abstract-target ( name # name of the target in Jamfile self.name = $(new-name) ; } } -class abstract-target ; # Project target class (derived from 'abstract-target') # @@ -162,19 +164,23 @@ class abstract-target ; # targets. # - The first time 'main-target' or 'has-main-target' rule is called, # all alternatives are enumerated an main targets are created. -rule project-target ( name : project : requirements * : default-build * ) +xclass project-target : abstract-target { import project targets ; import path ; import print ; import property-set ; import set : difference : set.difference ; + import class : xnew ; + + rule __init__ ( name : project : requirements * : default-build * ) + { + abstract-target.__init__ $(name) : $(project) ; + + self.requirements = $(requirements) ; + self.default-build = $(default-build) ; + } - abstract-target.__init__ $(name) : $(project) ; - - self.requirements = $(requirements) ; - self.default-build = $(default-build) ; - rule set-property-adjuster ( property-adjuster ) { for local t in [ targets-to-build ] @@ -297,7 +303,7 @@ rule project-target ( name : project : requirements * : default-build * ) if ! $(target) { self.main-target.$(name) = - [ new main-target $(name) : $(self.project) ] ; + [ xnew main-target $(name) : $(self.project) ] ; self.main-targets += $(name) ; target = $(self.main-target.$(name)) ; } @@ -329,8 +335,6 @@ rule project-target ( name : project : requirements * : default-build * ) } } -class project-target : abstract-target ; - # Helper rules to detect cycles in main target references @@ -358,10 +362,8 @@ local rule end-building ( main-target-instance ) # A named top-level target in Jamfile -rule main-target ( name : project ) +xclass main-target : abstract-target { - abstract-target.__init__ $(name) : $(project) ; - import errors : error ; import assert ; import numbers : range ; @@ -369,6 +371,13 @@ rule main-target ( name : project ) import print ; import build-request feature property-set ; import targets : start-building end-building ; + import class : is-a ; + + rule __init__ ( name : project ) + { + abstract-target.__init__ $(name) : $(project) ; + } + # Add a new alternative for this target rule add-alternative ( target ) @@ -528,8 +537,6 @@ rule main-target ( name : project ) } -class main-target : abstract-target ; - # Helper for 'find', below. local rule remove-trailing-slash ( string ) { @@ -759,40 +766,42 @@ rule generate-dependencies ( property-set : project : generation-ps ) # alternative from sources. Allows sources to be either file or # other main target and handles generation of those dependency # targets. -rule basic-target ( name : project - : sources * : requirements * : - [property-set] default-build * : usage-requirements * ) -{ - abstract-target.__init__ $(name) : $(project) ; - +xclass basic-target : abstract-target +{ import build-request ; import virtual-target targets ; import property-set ; import set sequence errors ; - - self.sources = $(sources) ; - if ! $(requirements) { - requirements = [ property-set.empty ] ; - } - self.requirements = $(requirements) ; - if ! $(default-build) - { - default-build = [ property-set.empty ] ; - } - self.default-build = $(default-build) ; - if ! $(usage-requirements) - { - usage-requirements = [ property-set.empty ] ; - } - self.usage-requirements = $(usage-requirements) ; - - if $(sources:G) - { - errors.error "gristed element in sources for" [ full-name ] ; + import class : new xnew ; + + rule __init__ ( name : project + : sources * : requirements * : + default-build * : usage-requirements * ) + { + abstract-target.__init__ $(name) : $(project) ; + + self.sources = $(sources) ; + if ! $(requirements) { + requirements = [ property-set.empty ] ; + } + self.requirements = $(requirements) ; + if ! $(default-build) + { + default-build = [ property-set.empty ] ; + } + self.default-build = $(default-build) ; + if ! $(usage-requirements) + { + usage-requirements = [ property-set.empty ] ; + } + self.usage-requirements = $(usage-requirements) ; + + if $(sources:G) + { + errors.error "gristed element in sources for" [ full-name ] ; + } } - - - + rule default-build ( ) { return $(self.default-build) ; @@ -1032,18 +1041,19 @@ rule basic-target ( name : project } } -class basic-target : abstract-target ; - -rule typed-target ( name : project : type - : sources * : requirements * : default-build * : usage-requirements * ) +xclass typed-target : basic-target { - basic-target.__init__ $(name) : $(project) - : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; - - import generators ; - - self.type = $(type) ; + import generators ; + rule __init__ ( name : project : type + : sources * : requirements * : default-build * : usage-requirements * ) + { + basic-target.__init__ $(name) : $(project) + : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; + + self.type = $(type) ; + } + rule construct ( source-targets * : property-set ) { local r = [ generators.construct $(self.project) $(self.name) : $(self.type) @@ -1059,7 +1069,6 @@ rule typed-target ( name : project : type return $(r) ; } } -class typed-target : basic-target ; # Return the list of sources to use, if main target rule is invoked # with 'sources'. If there are any objects in 'sources', they are treated diff --git a/new/testing.jam b/new/testing.jam index ef5c67b7d..fcb83e4db 100644 --- a/new/testing.jam +++ b/new/testing.jam @@ -15,12 +15,15 @@ import toolset ; # lanch test programs. feature.feature testing.launcher : : optional free ; -rule unit-test-target-class ( name : project : sources * : requirements * - : default-build * ) +xclass unit-test-target-class : basic-target { - typed-target.__init__ $(name) : $(project) : EXE : $(sources) - : $(requirements) : $(default-build) ; - + rule __init__ ( name : project : sources * : requirements * + : default-build * ) + { + typed-target.__init__ $(name) : $(project) : EXE : $(sources) + : $(requirements) : $(default-build) ; + } + rule construct ( source-targets * : properties * ) { local result = @@ -55,7 +58,7 @@ rule unit-test ( target-name : sources * : requirements * ) # TODO: what to do with default build? targets.main-target-alternative - [ new unit-test-target-class $(target-name) : $(project) : $(sources) + [ xnew unit-test-target-class $(target-name) : $(project) : $(sources) : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ; diff --git a/new/type.jam b/new/type.jam index 77b67ec7c..1c54cc665 100644 --- a/new/type.jam +++ b/new/type.jam @@ -8,7 +8,7 @@ import feature ; import generators : * ; -import class : class new ; +import class : class new xnew ; import errors ; import property ; import scanner ; @@ -234,7 +234,7 @@ rule main-target-rule ( name : sources * : requirements * : default-build * import targets ; return [ targets.main-target-alternative - [ new typed-target $(name) : $(project) : $(.main-target-type.$(rulename)) + [ xnew typed-target $(name) : $(project) : $(.main-target-type.$(rulename)) : [ targets.main-target-sources $(sources) : $(name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] diff --git a/test/unused/project-root.jam b/test/unused/project-root.jam index 8994c99d2..6e839204e 100644 --- a/test/unused/project-root.jam +++ b/test/unused/project-root.jam @@ -3,17 +3,20 @@ import type ; import generators ; import print ; import virtual-target ; -import class : class new ; +import class : class new xnew ; import modules ; import targets ; type.register X : x ; -rule test-target-class ( name : project ) +xclass test-target-class : basic-target { - basic-target.__init__ $(name) : $(project) ; - + rule __init__ ( name : project ) + { + basic-target.__init__ $(name) : $(project) ; + } + rule construct ( source-targets * : property-set ) { if [ modules.peek : GENERATE_NOTHING ] @@ -38,14 +41,13 @@ rule test-target-class ( name : project ) return [ property-set.create FOO ] ; } } -class test-target-class : basic-target ; rule make-b-main-target { local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new test-target-class b : $(project) ] ; + [ xnew test-target-class b : $(project) ] ; } IMPORT $(__name__) : make-b-main-target : : make-b-main-target ; diff --git a/tools/stlport.jam b/tools/stlport.jam index 41df760e0..452a3db21 100644 --- a/tools/stlport.jam +++ b/tools/stlport.jam @@ -35,7 +35,7 @@ import feature : feature subfeature ; import project ; -import class : class new ; +import class : class new xnew ; import targets ; import property-set ; @@ -76,15 +76,18 @@ subfeature stdlib stlport : extensions : noext : optional propagated ; # - when host iostreams are used, we really should produce nothing. It would # be hard/impossible to achieve this using prebuilt targets. -rule stlport-target-class ( project : headers ? : libraries ? : requirements * ) +xclass stlport-target-class : basic-target { - basic-target.__init__ stlport : $(project) : : $(requirements) ; - self.headers = $(headers) ; - self.libraries = $(libraries) ; - import feature project type errors generators ; - import set : difference ; + import set : difference ; + rule __init__ ( project : headers ? : libraries ? : requirements * ) + { + basic-target.__init__ stlport : $(project) : : $(requirements) ; + self.headers = $(headers) ; + self.libraries = $(libraries) ; + } + rule generate ( property-set ) { # Since this target is built with stlport, it will also @@ -159,15 +162,13 @@ rule stlport-target-class ( project : headers ? : libraries ? : requirements * ) return [ property-set.create $(usage-requirements) ] ; } } -class stlport-target-class : basic-target ; - rule stlport-target ( headers ? : libraries ? : requirements * ) { local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new stlport-target-class $(project) : $(headers) : $(libraries) + [ xnew stlport-target-class $(project) : $(headers) : $(libraries) : [ targets.main-target-requirements $(requirements) : $(project) ] ] ; } diff --git a/v2/build/alias.jam b/v2/build/alias.jam index 587b019c0..b4cb60e60 100644 --- a/v2/build/alias.jam +++ b/v2/build/alias.jam @@ -24,32 +24,33 @@ # import targets ; -import class : class new ; +import class : class new xnew ; import property ; import errors : error ; import type : type ; import regex ; -rule alias-target-class ( name : project : sources * : requirements * : default-build * ) +xclass alias-target-class : basic-target { - basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) - : $(default-build) ; - + rule __init__ ( name : project : sources * : requirements * : default-build * ) + { + basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) + : $(default-build) ; + } + rule construct ( source-targets * : property-set ) { return $(source-targets) ; } } -class alias-target-class : basic-target ; - # Declares the 'alias' target. It will build sources, and return them unaltered. rule alias ( name : sources * : requirements * : default-build * ) { local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new alias-target-class $(name) : $(project) + [ xnew alias-target-class $(name) : $(project) : [ targets.main-target-sources $(sources) : $(name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] diff --git a/v2/build/project.jam b/v2/build/project.jam index 03fccc2c5..74af9a763 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -44,7 +44,7 @@ import errors : error ; import project-roots ; import print ; -import class : class new ; +import class : class new xnew ; import errors ; import assert ; import property-set ; @@ -524,7 +524,7 @@ rule target ( project-module ) { if ! $(.target.$(project-module)) { - .target.$(project-module) = [ new project-target $(project-module) + .target.$(project-module) = [ xnew project-target $(project-module) : $(project-module) : [ attribute $(project-module) requirements ] ] ; } diff --git a/v2/build/targets.jam b/v2/build/targets.jam index ec681f0a2..c591d695d 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -80,19 +80,22 @@ import path ; import set ; # Base class for all abstract targets. -rule abstract-target ( name # name of the target in Jamfile - : project # the project module where the target is declared - ) +xclass abstract-target { - import project ; + import project ; - # Note: it might seem that we don't need either name or project at all. - # However, there are places where we really need it. One example is error - # messages which should name problematic targets. Another is setting correct - # paths for sources and generated files. - - self.name = $(name) ; - self.project = $(project) ; + rule __init__ ( name # name of the target in Jamfile + : project # the project module where the target is declared + ) + { + # Note: it might seem that we don't need either name or project at all. + # However, there are places where we really need it. One example is error + # messages which should name problematic targets. Another is setting correct + # paths for sources and generated files. + + self.name = $(name) ; + self.project = $(project) ; + } # Returns the name of this target. rule name ( ) @@ -144,7 +147,6 @@ rule abstract-target ( name # name of the target in Jamfile self.name = $(new-name) ; } } -class abstract-target ; # Project target class (derived from 'abstract-target') # @@ -162,19 +164,23 @@ class abstract-target ; # targets. # - The first time 'main-target' or 'has-main-target' rule is called, # all alternatives are enumerated an main targets are created. -rule project-target ( name : project : requirements * : default-build * ) +xclass project-target : abstract-target { import project targets ; import path ; import print ; import property-set ; import set : difference : set.difference ; + import class : xnew ; + + rule __init__ ( name : project : requirements * : default-build * ) + { + abstract-target.__init__ $(name) : $(project) ; + + self.requirements = $(requirements) ; + self.default-build = $(default-build) ; + } - abstract-target.__init__ $(name) : $(project) ; - - self.requirements = $(requirements) ; - self.default-build = $(default-build) ; - rule set-property-adjuster ( property-adjuster ) { for local t in [ targets-to-build ] @@ -297,7 +303,7 @@ rule project-target ( name : project : requirements * : default-build * ) if ! $(target) { self.main-target.$(name) = - [ new main-target $(name) : $(self.project) ] ; + [ xnew main-target $(name) : $(self.project) ] ; self.main-targets += $(name) ; target = $(self.main-target.$(name)) ; } @@ -329,8 +335,6 @@ rule project-target ( name : project : requirements * : default-build * ) } } -class project-target : abstract-target ; - # Helper rules to detect cycles in main target references @@ -358,10 +362,8 @@ local rule end-building ( main-target-instance ) # A named top-level target in Jamfile -rule main-target ( name : project ) +xclass main-target : abstract-target { - abstract-target.__init__ $(name) : $(project) ; - import errors : error ; import assert ; import numbers : range ; @@ -369,6 +371,13 @@ rule main-target ( name : project ) import print ; import build-request feature property-set ; import targets : start-building end-building ; + import class : is-a ; + + rule __init__ ( name : project ) + { + abstract-target.__init__ $(name) : $(project) ; + } + # Add a new alternative for this target rule add-alternative ( target ) @@ -528,8 +537,6 @@ rule main-target ( name : project ) } -class main-target : abstract-target ; - # Helper for 'find', below. local rule remove-trailing-slash ( string ) { @@ -759,40 +766,42 @@ rule generate-dependencies ( property-set : project : generation-ps ) # alternative from sources. Allows sources to be either file or # other main target and handles generation of those dependency # targets. -rule basic-target ( name : project - : sources * : requirements * : - [property-set] default-build * : usage-requirements * ) -{ - abstract-target.__init__ $(name) : $(project) ; - +xclass basic-target : abstract-target +{ import build-request ; import virtual-target targets ; import property-set ; import set sequence errors ; - - self.sources = $(sources) ; - if ! $(requirements) { - requirements = [ property-set.empty ] ; - } - self.requirements = $(requirements) ; - if ! $(default-build) - { - default-build = [ property-set.empty ] ; - } - self.default-build = $(default-build) ; - if ! $(usage-requirements) - { - usage-requirements = [ property-set.empty ] ; - } - self.usage-requirements = $(usage-requirements) ; - - if $(sources:G) - { - errors.error "gristed element in sources for" [ full-name ] ; + import class : new xnew ; + + rule __init__ ( name : project + : sources * : requirements * : + default-build * : usage-requirements * ) + { + abstract-target.__init__ $(name) : $(project) ; + + self.sources = $(sources) ; + if ! $(requirements) { + requirements = [ property-set.empty ] ; + } + self.requirements = $(requirements) ; + if ! $(default-build) + { + default-build = [ property-set.empty ] ; + } + self.default-build = $(default-build) ; + if ! $(usage-requirements) + { + usage-requirements = [ property-set.empty ] ; + } + self.usage-requirements = $(usage-requirements) ; + + if $(sources:G) + { + errors.error "gristed element in sources for" [ full-name ] ; + } } - - - + rule default-build ( ) { return $(self.default-build) ; @@ -1032,18 +1041,19 @@ rule basic-target ( name : project } } -class basic-target : abstract-target ; - -rule typed-target ( name : project : type - : sources * : requirements * : default-build * : usage-requirements * ) +xclass typed-target : basic-target { - basic-target.__init__ $(name) : $(project) - : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; - - import generators ; - - self.type = $(type) ; + import generators ; + rule __init__ ( name : project : type + : sources * : requirements * : default-build * : usage-requirements * ) + { + basic-target.__init__ $(name) : $(project) + : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; + + self.type = $(type) ; + } + rule construct ( source-targets * : property-set ) { local r = [ generators.construct $(self.project) $(self.name) : $(self.type) @@ -1059,7 +1069,6 @@ rule typed-target ( name : project : type return $(r) ; } } -class typed-target : basic-target ; # Return the list of sources to use, if main target rule is invoked # with 'sources'. If there are any objects in 'sources', they are treated diff --git a/v2/build/type.jam b/v2/build/type.jam index 77b67ec7c..1c54cc665 100644 --- a/v2/build/type.jam +++ b/v2/build/type.jam @@ -8,7 +8,7 @@ import feature ; import generators : * ; -import class : class new ; +import class : class new xnew ; import errors ; import property ; import scanner ; @@ -234,7 +234,7 @@ rule main-target-rule ( name : sources * : requirements * : default-build * import targets ; return [ targets.main-target-alternative - [ new typed-target $(name) : $(project) : $(.main-target-type.$(rulename)) + [ xnew typed-target $(name) : $(project) : $(.main-target-type.$(rulename)) : [ targets.main-target-sources $(sources) : $(name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] diff --git a/v2/test/unused/project-root.jam b/v2/test/unused/project-root.jam index 8994c99d2..6e839204e 100644 --- a/v2/test/unused/project-root.jam +++ b/v2/test/unused/project-root.jam @@ -3,17 +3,20 @@ import type ; import generators ; import print ; import virtual-target ; -import class : class new ; +import class : class new xnew ; import modules ; import targets ; type.register X : x ; -rule test-target-class ( name : project ) +xclass test-target-class : basic-target { - basic-target.__init__ $(name) : $(project) ; - + rule __init__ ( name : project ) + { + basic-target.__init__ $(name) : $(project) ; + } + rule construct ( source-targets * : property-set ) { if [ modules.peek : GENERATE_NOTHING ] @@ -38,14 +41,13 @@ rule test-target-class ( name : project ) return [ property-set.create FOO ] ; } } -class test-target-class : basic-target ; rule make-b-main-target { local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new test-target-class b : $(project) ] ; + [ xnew test-target-class b : $(project) ] ; } IMPORT $(__name__) : make-b-main-target : : make-b-main-target ; diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 947f18ca7..d0884d215 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -379,14 +379,17 @@ type.set-scanner CPP : c-scanner ; type.register H : h hpp ; type.register C : c ; -rule lib-target-class ( name : project - : sources * : requirements * : default-build * : usage-requirements * ) -{ - basic-target.__init__ $(name) : $(project) - : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; +xclass lib-target-class : basic-target +{ + import generators : construct : generators.construct ; - import generators : construct : generators.construct ; - + rule __init__ ( name : project + : sources * : requirements * : default-build * : usage-requirements * ) + { + basic-target.__init__ $(name) : $(project) + : $(sources) : $(requirements) : $(default-build) : $(usage-requirements) ; + } + rule construct ( source-targets * : property-set ) { local properties = [ $(property-set).raw ] ; @@ -423,7 +426,6 @@ rule lib-target-class ( name : project } } -class lib-target-class : basic-target ; rule lib ( name : sources * : requirements * : default-build * : usage-requirements * ) @@ -433,7 +435,7 @@ rule lib ( name : sources * : requirements * : default-build * # This is a circular module dependency, so it must be imported here import targets ; targets.main-target-alternative - [ new lib-target-class $(name) : $(project) + [ xnew lib-target-class $(name) : $(project) : [ targets.main-target-sources $(sources) : $(name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] diff --git a/v2/tools/make.jam b/v2/tools/make.jam index 7b36e7856..9e7b988ec 100644 --- a/v2/tools/make.jam +++ b/v2/tools/make.jam @@ -13,16 +13,20 @@ import type : type ; import regex ; import property-set ; -rule make-target-class ( name : project : sources * : requirements * - : make-rule + : default-build * ) +xclass make-target-class : basic-target { - import type regex virtual-target ; + import type regex virtual-target ; + import class : xnew ; - basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) - : $(default-build) ; + rule __init__ ( name : project : sources * : requirements * + : make-rule + : default-build * ) + { + basic-target.__init__ $(name) : $(project) : $(sources) : $(requirements) + : $(default-build) ; - self.make-rule = $(make-rule) ; - + self.make-rule = $(make-rule) ; + } + rule construct ( source-targets * : property-set ) { local t = [ xnew file-target $(self.name:S=) : [ type.type $(self.name:S) ] @@ -34,7 +38,6 @@ rule make-target-class ( name : project : sources * : requirements * return [ virtual-target.register $(t) ] ; } } -class make-target-class : basic-target ; # Declares the 'make' main target. rule make ( target-name : sources * : generating-rule + : requirements * @@ -51,7 +54,7 @@ rule make ( target-name : sources * : generating-rule + : requirements * } targets.main-target-alternative - [ new make-target-class $(target-name) : $(caller) + [ xnew make-target-class $(target-name) : $(caller) : [ targets.main-target-sources $(sources) : $(target-name) ] : [ targets.main-target-requirements $(requirements) : $(caller) ] : $(generating-rule) diff --git a/v2/tools/stage.jam b/v2/tools/stage.jam index 2e2434dee..51a2fefb1 100644 --- a/v2/tools/stage.jam +++ b/v2/tools/stage.jam @@ -36,13 +36,17 @@ import type ; import regex ; import generators ; -rule stage-target-class ( name-and-dir : project : sources * : requirements * : default-build * ) +xclass stage-target-class : basic-target { - basic-target.__init__ $(name-and-dir) : $(project) : $(sources) : $(requirements) - : $(default-build) ; - - import feature project type errors generators ; + import feature project type errors generators ; + import class : xnew ; + rule __init__ ( name-and-dir : project : sources * : requirements * : default-build * ) + { + basic-target.__init__ $(name-and-dir) : $(project) : $(sources) : $(requirements) + : $(default-build) ; + } + rule construct ( source-targets * : property-set ) { local name = [ $(property-set).get ] ; @@ -107,8 +111,6 @@ rule stage-target-class ( name-and-dir : project : sources * : requirements * : } -class stage-target-class : basic-target ; - # Declare staged version of the EXE type. Generator for this type will # cause relinking to the new location. type.register STAGED_EXE : : EXE ; @@ -168,7 +170,7 @@ rule stage ( name : sources * : requirements * : default-build * ) local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new stage-target-class $(name) : $(project) : $(sources) + [ xnew stage-target-class $(name) : $(project) : $(sources) : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ; diff --git a/v2/tools/stlport.jam b/v2/tools/stlport.jam index 41df760e0..452a3db21 100644 --- a/v2/tools/stlport.jam +++ b/v2/tools/stlport.jam @@ -35,7 +35,7 @@ import feature : feature subfeature ; import project ; -import class : class new ; +import class : class new xnew ; import targets ; import property-set ; @@ -76,15 +76,18 @@ subfeature stdlib stlport : extensions : noext : optional propagated ; # - when host iostreams are used, we really should produce nothing. It would # be hard/impossible to achieve this using prebuilt targets. -rule stlport-target-class ( project : headers ? : libraries ? : requirements * ) +xclass stlport-target-class : basic-target { - basic-target.__init__ stlport : $(project) : : $(requirements) ; - self.headers = $(headers) ; - self.libraries = $(libraries) ; - import feature project type errors generators ; - import set : difference ; + import set : difference ; + rule __init__ ( project : headers ? : libraries ? : requirements * ) + { + basic-target.__init__ stlport : $(project) : : $(requirements) ; + self.headers = $(headers) ; + self.libraries = $(libraries) ; + } + rule generate ( property-set ) { # Since this target is built with stlport, it will also @@ -159,15 +162,13 @@ rule stlport-target-class ( project : headers ? : libraries ? : requirements * ) return [ property-set.create $(usage-requirements) ] ; } } -class stlport-target-class : basic-target ; - rule stlport-target ( headers ? : libraries ? : requirements * ) { local project = [ CALLER_MODULE ] ; targets.main-target-alternative - [ new stlport-target-class $(project) : $(headers) : $(libraries) + [ xnew stlport-target-class $(project) : $(headers) : $(libraries) : [ targets.main-target-requirements $(requirements) : $(project) ] ] ; } diff --git a/v2/tools/symlink.jam b/v2/tools/symlink.jam index 89bcc6ef6..66f997ce2 100644 --- a/v2/tools/symlink.jam +++ b/v2/tools/symlink.jam @@ -14,39 +14,42 @@ feature.feature symlink-location : project-relative build-relative : incidental # The class representing "symlink" targets. # -rule symlink-targets ( - project - : targets * - : sources * - ) +xclass symlink-targets : basic-target { import numbers modules class property project ; - # Generate a fake name for now. Need unnamed targets eventually. - local c = [ modules.peek symlink : .count ] ; - modules.poke symlink : .count : [ numbers.increment $(c) ] ; - local fake-name = symlink#$(c) ; + rule __init__ ( + project + : targets * + : sources * + ) + { + # Generate a fake name for now. Need unnamed targets eventually. + local c = [ modules.peek symlink : .count ] ; + modules.poke symlink : .count : [ numbers.increment $(c) ] ; + local fake-name = symlink#$(c) ; - basic-target.__init__ $(fake-name) : $(project) : $(sources) ; + basic-target.__init__ $(fake-name) : $(project) : $(sources) ; - # Remember the targets to map the sources onto. Pad or truncate - # to fit the sources given. - self.targets = ; - for local source in $(sources) - { - if $(targets) + # Remember the targets to map the sources onto. Pad or truncate + # to fit the sources given. + self.targets = ; + for local source in $(sources) { - self.targets += $(targets[1]) ; - targets = $(targets[2-]) ; + if $(targets) + { + self.targets += $(targets[1]) ; + targets = $(targets[2-]) ; + } + else + { + self.targets += $(source) ; + } } - else - { - self.targets += $(source) ; - } - } - # The virtual targets corresponding to the given targets. - self.virtual-targets = ; + # The virtual targets corresponding to the given targets. + self.virtual-targets = ; + } rule construct ( source-targets * : property-set ) { @@ -71,7 +74,6 @@ rule symlink-targets ( return $(self.virtual-targets) ; } } -class.class symlink-targets : basic-target ; # Creates a symbolic link from a set of targets to a set of sources. # The targets and sources map one to one. The symlinks generated are @@ -95,7 +97,7 @@ rule symlink ( local project = [ CALLER_MODULE ] ; return [ targets.main-target-alternative - [ class.new symlink-targets $(project) : $(targets) : + [ class.xnew symlink-targets $(project) : $(targets) : # Note: inline targets are not supported for symlink, intentionally, # since it's used to linking existing non-local targets. $(sources) ] ] ; diff --git a/v2/tools/testing.jam b/v2/tools/testing.jam index ef5c67b7d..fcb83e4db 100644 --- a/v2/tools/testing.jam +++ b/v2/tools/testing.jam @@ -15,12 +15,15 @@ import toolset ; # lanch test programs. feature.feature testing.launcher : : optional free ; -rule unit-test-target-class ( name : project : sources * : requirements * - : default-build * ) +xclass unit-test-target-class : basic-target { - typed-target.__init__ $(name) : $(project) : EXE : $(sources) - : $(requirements) : $(default-build) ; - + rule __init__ ( name : project : sources * : requirements * + : default-build * ) + { + typed-target.__init__ $(name) : $(project) : EXE : $(sources) + : $(requirements) : $(default-build) ; + } + rule construct ( source-targets * : properties * ) { local result = @@ -55,7 +58,7 @@ rule unit-test ( target-name : sources * : requirements * ) # TODO: what to do with default build? targets.main-target-alternative - [ new unit-test-target-class $(target-name) : $(project) : $(sources) + [ xnew unit-test-target-class $(target-name) : $(project) : $(sources) : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build $(default-build) : $(project) ] ] ;