From 26da990bc67f44cf519b85ea0b6f0bce8ebc2fbb Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 4 Aug 2003 09:13:22 +0000 Subject: [PATCH] Make virtual-target hierarchy use new style classes. [SVN r19425] --- src/build/generators.jam | 6 +-- src/build/modifiers.jam | 4 +- src/build/virtual-target.jam | 82 ++++++++++++++++++++---------------- src/tools/builtin.jam | 33 +++++++-------- src/tools/make.jam | 4 +- src/tools/prebuilt.jam | 4 +- src/tools/stage.jam | 6 +-- src/tools/symlink.jam | 2 +- src/tools/testing.jam | 4 +- 9 files changed, 76 insertions(+), 69 deletions(-) diff --git a/src/build/generators.jam b/src/build/generators.jam index 08e9e0518..aace22923 100644 --- a/src/build/generators.jam +++ b/src/build/generators.jam @@ -40,7 +40,7 @@ # 'construct' rule has a parameter, telling if multiple targets can be returned. If # the parameter is false, conversion of extra targets is not performed. -import class : class new is-a ; +import class : class new is-a xnew ; import container : vector ; import numbers : range ; import utility : str equal ; @@ -434,7 +434,7 @@ rule generator ( generated-name = $(name) ; } - targets += [ new file-target $(generated-name) : $(t) : $(project) ] ; + targets += [ xnew file-target $(generated-name) : $(t) : $(project) ] ; } # Assign an action for each target local action = [ action-class ] ; @@ -907,7 +907,7 @@ local rule construct-with-caching ( } else { - local ut = [ new file-target % : [ $(t).type ] : "no project" ] ; + local ut = [ xnew file-target % : [ $(t).type ] : "no project" ] ; cresult = [ construct $(project) : $(target-type) $(multiple) : $(property-set) : $(ut) ] ; .transformation.cache.$(signature) = $(cresult) ; diff --git a/src/build/modifiers.jam b/src/build/modifiers.jam index 9014491e8..53e44ddc3 100644 --- a/src/build/modifiers.jam +++ b/src/build/modifiers.jam @@ -13,7 +13,7 @@ import modules ; import feature ; import errors ; import type ; -import class : class new ; +import class : class new xnew ; import generators : generator ; import property ; import virtual-target ; @@ -118,7 +118,7 @@ rule modifier ( new-name ?= [ $(target).name ] ; new-type ?= [ $(target).type ] ; new-project ?= [ $(target).project ] ; - local result = [ new file-target $(new-name) : $(new-type) : $(new-project) ] ; + local result = [ xnew file-target $(new-name) : $(new-type) : $(new-project) ] ; if [ $(target).dependencies ] { $(result).depends [ $(target).dependencies ] ; } $(result).suffix [ $(target).suffix ] ; diff --git a/src/build/virtual-target.jam b/src/build/virtual-target.jam index 568d0f4a4..4a8934d8d 100644 --- a/src/build/virtual-target.jam +++ b/src/build/virtual-target.jam @@ -8,7 +8,7 @@ # when searching for possible transormation sequences, when it's not known # if particular target should be created at all. -import class : class new ; +import class : class new xnew ; import path property-set utility sequence errors ; # +--------------------------+ @@ -63,16 +63,19 @@ import path property-set utility sequence errors ; # building, if needed. However, it can be also dropped, which allows # to search for different transformation and select only one. # -rule virtual-target ( name # Name of this target -- specifies the name of - : project # Project to which this target belongs - ) +xclass virtual-target { - import virtual-target utility scanner ; + import virtual-target utility scanner ; + + rule __init__ ( name # Name of this target -- specifies the name of + : project # Project to which this target belongs + ) + { + self.name = $(name) ; + self.project = $(project) ; + self.dependencies = ; + } - self.name = $(name) ; - self.project = $(project) ; - self.dependencies = ; - # Name of this target. rule name ( ) { return $(self.name) ; } @@ -186,8 +189,6 @@ rule virtual-target ( name # Name of this target -- specifies the name of } -class virtual-target ; - # Target which correspond to a file. The exact mapping for file # is not yet specified in this class. (TODO: Actually, the class name @@ -199,17 +200,21 @@ class virtual-target ; # The target's grist is concatenation of project's location, # properties of action (for derived files), and, optionally, # value identifying the main target. -rule abstract-file-target ( name - : type ? # Optional type for this target +xclass abstract-file-target : virtual-target +{ + import project regex sequence path type ; + + rule __init__ ( name + : type ? # Optional type for this target : project ) -{ - virtual-target.__init__ $(name) : $(project) ; - import project regex sequence path type ; - - self.type = $(type) ; - self.action = ; - + { + virtual-target.__init__ $(name) : $(project) ; + + self.type = $(type) ; + self.action = ; + } + rule type ( ) { return $(self.type) ; } rule set-type ( type ) { @@ -397,7 +402,6 @@ rule abstract-file-target ( name } } -class abstract-file-target : virtual-target ; # File target with explicitly known location. # @@ -413,15 +417,19 @@ class abstract-file-target : virtual-target ; # - the value passed to the 'suffix' method, if any, or # - the suffix which correspond to the target's type. # -rule file-target ( - name - : type ? # Optional type for this target - : project - ) +xclass file-target : abstract-file-target { - abstract-file-target.__init__ $(name) : $(type) : $(project) ; - import common ; + import common ; + rule __init__ ( + name + : type ? # Optional type for this target + : project + ) + { + abstract-file-target.__init__ $(name) : $(type) : $(project) ; + } + rule actualize-location ( target ) { if $(self.path) @@ -503,12 +511,13 @@ rule file-target ( } -class file-target : abstract-file-target ; - - -rule notfile-target ( name : project ) +xclass notfile-target : abstract-file-target { - abstract-file-target.__init__ $(name) : : $(project) ; + rule __init__ ( name : project ) + { + abstract-file-target.__init__ $(name) : : $(project) ; + } + rule actualize-location ( target ) { @@ -516,7 +525,6 @@ rule notfile-target ( name : project ) ALWAYS $(target) ; } } -class notfile-target : abstract-file-target ; # Returns the binding for the given actual target. @@ -711,11 +719,11 @@ rule from-file ( file : project ) if ! $(type) { # warning "cannot determine type for file $(file)" ; - result = [ new file-target $(file) : : $(project) ] ; + result = [ xnew file-target $(file) : : $(project) ] ; } else { - local v = [ new file-target $(name) : $(type) : $(project) ] ; + local v = [ xnew file-target $(name) : $(type) : $(project) ] ; $(v).suffix [ MATCH ^.(.*)$ : $(file:S) ] ; result = $(v) ; } @@ -854,7 +862,7 @@ rule clone-template ( target dont-recurse ? : new-source ) } else { - local cloned = [ new file-target $(new-name) : [ $(target).type ] : + local cloned = [ xnew file-target $(new-name) : [ $(target).type ] : [ $(new-source).project ] ] ; if ! $(dont-recurse) && [ $(target).action ] diff --git a/src/tools/builtin.jam b/src/tools/builtin.jam index 7ff244e4b..cc1b3ac0a 100644 --- a/src/tools/builtin.jam +++ b/src/tools/builtin.jam @@ -168,20 +168,23 @@ rule handle-ndebug ( property : properties * ) feature.action speed : handle-ndebug ; - -rule searched-lib-target ( name - : project - : shared ? - : real-name ? - : search * - ) +xclass searched-lib-target : abstract-file-target { - abstract-file-target.__init__ $(name) : SEARCHED_LIB : $(project) ; + rule __init__ ( name + : project + : shared ? + : real-name ? + : search * + ) + { + abstract-file-target.__init__ $(name) : SEARCHED_LIB : $(project) ; + + self.shared = $(shared) ; + self.real-name = $(real-name) ; + self.real-name ?= $(name) ; + self.search = $(search) ; + } - self.shared = $(shared) ; - self.real-name = $(real-name) ; - self.real-name ?= $(name) ; - self.search = $(search) ; rule shared ( ) { @@ -208,10 +211,6 @@ rule searched-lib-target ( name } } - -class searched-lib-target : abstract-file-target ; - - type.register LIB : : : main ; # register the given type on the specified OSes, or on remaining OSes @@ -466,7 +465,7 @@ rule searched-lib-generator ( ) shared = true ; } - local t = [ new searched-lib-target $(name) : $(project) : $(shared) + local t = [ xnew searched-lib-target $(name) : $(project) : $(shared) : [ feature.get-values : $(properties) ] : [ feature.get-values : $(properties) ] ] ; diff --git a/src/tools/make.jam b/src/tools/make.jam index fdc614a45..519e183a6 100644 --- a/src/tools/make.jam +++ b/src/tools/make.jam @@ -6,7 +6,7 @@ # This module defines the 'make' main target rule. import targets ; -import class : class new ; +import class : class new xnew ; import property ; import errors : error ; import type : type ; @@ -25,7 +25,7 @@ rule make-target-class ( name : project : sources * : requirements * rule construct ( source-targets * : property-set ) { - local t = [ new file-target $(self.name:S=) : [ type.type $(self.name:S) ] + local t = [ xnew file-target $(self.name:S=) : [ type.type $(self.name:S) ] : $(self.project) ] ; $(t).suffix [ regex.match .(.*) : $(self.name:S) ] ; local a = [ new action $(t) : $(source-targets) : $(self.make-rule) diff --git a/src/tools/prebuilt.jam b/src/tools/prebuilt.jam index 0342c920c..3852029a2 100644 --- a/src/tools/prebuilt.jam +++ b/src/tools/prebuilt.jam @@ -6,7 +6,7 @@ # This module defines a special generator, which handles targets with # property. It allows to use prebuilt targets. -import class : class new ; +import class : class new xnew ; import generators ; import feature : feature ; @@ -29,7 +29,7 @@ rule prebuilt-file-generator errors.error "Unknown type for prebuilt target " $(name) in $(project) ; } - local t = [ new file-target $(filename:S=:D=) : $(type) : $(project) ] ; + local t = [ xnew file-target $(filename:S=:D=) : $(type) : $(project) ] ; $(t).set-path [ path.parent $(filename) ] ; # By default, Boost.Build determines the suffix of file from its type. # Since we already have file, specify suffix explicitly. diff --git a/src/tools/stage.jam b/src/tools/stage.jam index ed6192b56..b0e4b36af 100644 --- a/src/tools/stage.jam +++ b/src/tools/stage.jam @@ -28,7 +28,7 @@ # one target can be specified in sources. import targets ; -import class : class new ; +import class : class new xnew ; import property ; import errors : error ; import type : type ; @@ -85,7 +85,7 @@ rule stage-target-class ( name-and-dir : project : sources * : requirements * : n = $(name) ; } - i2 = [ new file-target $(n:D=) : [ $(i).type ] + i2 = [ xnew file-target $(n:D=) : [ $(i).type ] : $(self.project) ] ; local a = [ new action $(i2) : $(i) : common.copy ] ; $(i2).suffix [ $(i).suffix ] ; @@ -123,7 +123,7 @@ rule stage-exe-generator # FIXME: this must become some rule in virtual-target module # we're cloning the target and action. local n = [ $(source).name ] ; - local cloned-target = [ new file-target $(n:D=) : [ $(source).type ] + local cloned-target = [ xnew file-target $(n:D=) : [ $(source).type ] : $(project) ] ; local d = [ $(source).dependencies ] ; if $(d) diff --git a/src/tools/symlink.jam b/src/tools/symlink.jam index cccc5ef64..1050a4343 100644 --- a/src/tools/symlink.jam +++ b/src/tools/symlink.jam @@ -54,7 +54,7 @@ rule symlink-targets ( for local t in $(source-targets) { local s = $(self.targets[$(i)]) ; - local vt = [ class.new file-target $(s:D=) : [ $(t).type ] : $(self.project) ] ; + local vt = [ class.xnew file-target $(s:D=) : [ $(t).type ] : $(self.project) ] ; $(vt).action [ class.new action $(vt) : $(t) : symlink.ln : $(property-set) ] ; # Place the symlink in the directory relative to the project diff --git a/src/tools/testing.jam b/src/tools/testing.jam index 9e6b00e2b..01e3e2f2c 100644 --- a/src/tools/testing.jam +++ b/src/tools/testing.jam @@ -6,7 +6,7 @@ # Testing support. import targets ; -import class : class new ; +import class : class new xnew ; import property ; import feature ; import toolset ; @@ -27,7 +27,7 @@ rule unit-test-target-class ( name : project : sources * : requirements * [ typed-target.construct $(source-targets) : $(properties) ] ; local exe = $(result[1]) ; local exe-action = [ $(exe).action ] ; - local timestamp = [ new file-target $(self.name) : : $(self.project) ] ; + local timestamp = [ xnew file-target $(self.name) : : $(self.project) ] ; $(timestamp).suffix "passed" ; local a = [ new action $(timestamp) : $(exe) : testing.run :