From a8d2feea847d9dbd53220647d0886739dd3ce245 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 2 Dec 2002 07:20:37 +0000 Subject: [PATCH] Work on BB5. Mininal version of toolset initialization implemented. * new/gcc.jam (init): New rule. Allows to specify alternative gcc versions. * new/toolset.jam (using): New rule. (set-target-variables): Bufgix. I was making indirect call via variable with multiple values. * new/build-request.jam (looks-like-implicit-value): New rule. (from-command-line): Use the above. (convert-command-line-element): Don't validate elements with dashes (this probably must be fixed). [SVN r16468] --- new/build-request.jam | 40 ++++++++++++++++++++++++++++++++++---- new/gcc.jam | 33 ++++++++++++++++++++++++++++--- new/toolset.jam | 18 +++++++++++++---- v2/build/build-request.jam | 40 ++++++++++++++++++++++++++++++++++---- v2/build/toolset.jam | 18 +++++++++++++---- v2/gcc.jam | 33 ++++++++++++++++++++++++++++--- 6 files changed, 160 insertions(+), 22 deletions(-) diff --git a/new/build-request.jam b/new/build-request.jam index df91518d3..c937fe5b8 100644 --- a/new/build-request.jam +++ b/new/build-request.jam @@ -122,6 +122,26 @@ rule expand ( property-sets * : feature-space ? ) return $(result) ; } +# Returns true if 'v' is either implicit value, or +# the part before the first '-' symbol is implicit value +local rule looks-like-implicit-value ( v : feature-space ? ) +{ + feature-space ?= feature ; + + if [ $(feature-space).is-implicit-value $(v) ] + { + return true ; + } + else + { + local split = [ regex.split $(v) - ] ; + if [ $(feature-space).is-implicit-value $(split[1]) ] + { + return true ; + } + } +} + # Takes the command line tokens (such as taken from ARGV rule) and constructs # build request from it. @@ -143,7 +163,7 @@ rule from-command-line ( command-line * : feature-space ? ) # consists of implicit feature values. local fs = feature-space ; if [ MATCH "(.*=.*)" : $(e) ] - || [ $(feature-space).is-implicit-value $(e:D=) ] + || [ looks-like-implicit-value $(e:D=) : $(feature-space) ] { properties += [ convert-command-line-element $(e) : $(feature-space) ] ; } @@ -177,10 +197,16 @@ local rule convert-command-line-element ( e : feature-space ) lresult = [ regex.split $(p) "," ] ; } - for local p in $(lresult) - { - property.validate $(p) : $(feature-space) ; + if ! [ MATCH (.*-.*) : $(p) ] + { + # property.validate cannot handle subfeatures, + # so we avoid the check here. + for local p in $(lresult) + { + property.validate $(p) : $(feature-space) ; + } } + if ! $(result) { @@ -308,6 +334,12 @@ rule __test__ ( ) assert.equal [ $(r).get-at 1 ] : ; assert.equal [ $(r).get-at 2 ] : msvc gcc/static borland/static ; + + r = [ build-request.from-command-line bjam gcc-3.0 + : $(test-space) ] ; + assert.equal [ $(r).get-at 1 ] : ; + assert.equal [ $(r).get-at 2 ] : gcc-3.0 ; + } } diff --git a/new/gcc.jam b/new/gcc.jam index 26b57939c..0b4448734 100644 --- a/new/gcc.jam +++ b/new/gcc.jam @@ -4,6 +4,33 @@ import generators ; import os ; feature.extend toolset : gcc ; +feature.subfeature toolset gcc : version : : optional ; + +# Initializes the gcc toolset +# Each argument has the form: +# version binary-name [path] +# And specifies the name / path that should be used to invoke +# the specified gcc version. The default version will be always called +# with 'g++'. +rule init ( a1 * : a2 * : a3 * ) +{ + if $(a1) + { + local version = $(a1[1]) ; + local name = $(a1[2]) ; + local path = $(a1[3]) ; + + feature.extend-subfeature toolset gcc : version : $(version) ; + + # NOTE: this should be collapsed in one line once + # 'toolset.flags' supports specifying module name. + toolset.flags gcc.compile NAME gcc/$(version) : $(name) ; + toolset.flags gcc.link NAME gcc/$(version) : $(name) ; + toolset.flags gcc.link-dll NAME gcc/$(version) : $(name) ; + + # TODO: set path accordingly. + } +} # Declare generators generators.register-composing gcc.link : LIB OBJ : EXE : gcc ; @@ -22,7 +49,7 @@ toolset.flags gcc.compile INCLUDES ; actions compile { - g++ -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) + $(NAME:E=g++) -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) } # Declare flags and action for linking @@ -34,7 +61,7 @@ toolset.flags gcc.link LIBRARIES ; actions link bind LIBRARIES { - g++ $(OPTIONS) -L$(LINKPATH) -o $(<) $(>) $(LIBRARIES) -l$(FINDLIBS) + $(NAME:E=g++) $(OPTIONS) -L$(LINKPATH) -o $(<) $(>) $(LIBRARIES) -l$(FINDLIBS) } # Declare action for creating static libraries @@ -52,5 +79,5 @@ toolset.flags gcc.link-dll LIBRARIES ; actions link-dll bind LIBS { - g++ $(OPTIONS) -o $(<) -Wl,-soname,$(<[1]:D=) -shared $(>) $(LIBS) $(FINDLIBS) + $(NAME:E=g++) $(OPTIONS) -o $(<) -Wl,-soname,$(<[1]:D=) -shared $(>) $(LIBS) $(FINDLIBS) } diff --git a/new/toolset.jam b/new/toolset.jam index f0c8fb754..5af9c6842 100644 --- a/new/toolset.jam +++ b/new/toolset.jam @@ -10,6 +10,16 @@ import numbers ; .flag-no = 1 ; +# Initializes an additional toolset-like module. +# First load 'toolset-module' and then calls it's 'init' +# rule with trailing arguments +rule using ( toolset-module : * ) +{ + import $(toolset-module) ; + $(toolset-module).init $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; +} + + # Specifies the flags (variables) that must be set on targets under certain # conditions, described by arguments. rule flags ( rule-or-module # If contains dot, should be a rule name. @@ -45,7 +55,7 @@ rule flags ( rule-or-module # If contains dot, should be a rule name. rule set-target-variables ( rule-or-module target : properties * ) -{ +{ for local f in $(.$(rule-or-module).flags) { local variable = $(.$(rule-or-module).variable.$(f)) ; @@ -72,15 +82,15 @@ rule set-target-variables ( rule-or-module target : properties * ) for local r in $(requirements) { local item = [ feature.get-values $(r) : $(properties) ] ; - if $(item) + for local i in $(item) { if dependency in [ feature.attributes $(r:G) ] { - result += [ $(item).actualize ] ; + result += [ $(i).actualize ] ; } else { - result += $(item) ; + result += $(i) ; } } } diff --git a/v2/build/build-request.jam b/v2/build/build-request.jam index df91518d3..c937fe5b8 100644 --- a/v2/build/build-request.jam +++ b/v2/build/build-request.jam @@ -122,6 +122,26 @@ rule expand ( property-sets * : feature-space ? ) return $(result) ; } +# Returns true if 'v' is either implicit value, or +# the part before the first '-' symbol is implicit value +local rule looks-like-implicit-value ( v : feature-space ? ) +{ + feature-space ?= feature ; + + if [ $(feature-space).is-implicit-value $(v) ] + { + return true ; + } + else + { + local split = [ regex.split $(v) - ] ; + if [ $(feature-space).is-implicit-value $(split[1]) ] + { + return true ; + } + } +} + # Takes the command line tokens (such as taken from ARGV rule) and constructs # build request from it. @@ -143,7 +163,7 @@ rule from-command-line ( command-line * : feature-space ? ) # consists of implicit feature values. local fs = feature-space ; if [ MATCH "(.*=.*)" : $(e) ] - || [ $(feature-space).is-implicit-value $(e:D=) ] + || [ looks-like-implicit-value $(e:D=) : $(feature-space) ] { properties += [ convert-command-line-element $(e) : $(feature-space) ] ; } @@ -177,10 +197,16 @@ local rule convert-command-line-element ( e : feature-space ) lresult = [ regex.split $(p) "," ] ; } - for local p in $(lresult) - { - property.validate $(p) : $(feature-space) ; + if ! [ MATCH (.*-.*) : $(p) ] + { + # property.validate cannot handle subfeatures, + # so we avoid the check here. + for local p in $(lresult) + { + property.validate $(p) : $(feature-space) ; + } } + if ! $(result) { @@ -308,6 +334,12 @@ rule __test__ ( ) assert.equal [ $(r).get-at 1 ] : ; assert.equal [ $(r).get-at 2 ] : msvc gcc/static borland/static ; + + r = [ build-request.from-command-line bjam gcc-3.0 + : $(test-space) ] ; + assert.equal [ $(r).get-at 1 ] : ; + assert.equal [ $(r).get-at 2 ] : gcc-3.0 ; + } } diff --git a/v2/build/toolset.jam b/v2/build/toolset.jam index f0c8fb754..5af9c6842 100644 --- a/v2/build/toolset.jam +++ b/v2/build/toolset.jam @@ -10,6 +10,16 @@ import numbers ; .flag-no = 1 ; +# Initializes an additional toolset-like module. +# First load 'toolset-module' and then calls it's 'init' +# rule with trailing arguments +rule using ( toolset-module : * ) +{ + import $(toolset-module) ; + $(toolset-module).init $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; +} + + # Specifies the flags (variables) that must be set on targets under certain # conditions, described by arguments. rule flags ( rule-or-module # If contains dot, should be a rule name. @@ -45,7 +55,7 @@ rule flags ( rule-or-module # If contains dot, should be a rule name. rule set-target-variables ( rule-or-module target : properties * ) -{ +{ for local f in $(.$(rule-or-module).flags) { local variable = $(.$(rule-or-module).variable.$(f)) ; @@ -72,15 +82,15 @@ rule set-target-variables ( rule-or-module target : properties * ) for local r in $(requirements) { local item = [ feature.get-values $(r) : $(properties) ] ; - if $(item) + for local i in $(item) { if dependency in [ feature.attributes $(r:G) ] { - result += [ $(item).actualize ] ; + result += [ $(i).actualize ] ; } else { - result += $(item) ; + result += $(i) ; } } } diff --git a/v2/gcc.jam b/v2/gcc.jam index 26b57939c..0b4448734 100644 --- a/v2/gcc.jam +++ b/v2/gcc.jam @@ -4,6 +4,33 @@ import generators ; import os ; feature.extend toolset : gcc ; +feature.subfeature toolset gcc : version : : optional ; + +# Initializes the gcc toolset +# Each argument has the form: +# version binary-name [path] +# And specifies the name / path that should be used to invoke +# the specified gcc version. The default version will be always called +# with 'g++'. +rule init ( a1 * : a2 * : a3 * ) +{ + if $(a1) + { + local version = $(a1[1]) ; + local name = $(a1[2]) ; + local path = $(a1[3]) ; + + feature.extend-subfeature toolset gcc : version : $(version) ; + + # NOTE: this should be collapsed in one line once + # 'toolset.flags' supports specifying module name. + toolset.flags gcc.compile NAME gcc/$(version) : $(name) ; + toolset.flags gcc.link NAME gcc/$(version) : $(name) ; + toolset.flags gcc.link-dll NAME gcc/$(version) : $(name) ; + + # TODO: set path accordingly. + } +} # Declare generators generators.register-composing gcc.link : LIB OBJ : EXE : gcc ; @@ -22,7 +49,7 @@ toolset.flags gcc.compile INCLUDES ; actions compile { - g++ -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) + $(NAME:E=g++) -ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I$(INCLUDES) -c -o $(<) $(>) } # Declare flags and action for linking @@ -34,7 +61,7 @@ toolset.flags gcc.link LIBRARIES ; actions link bind LIBRARIES { - g++ $(OPTIONS) -L$(LINKPATH) -o $(<) $(>) $(LIBRARIES) -l$(FINDLIBS) + $(NAME:E=g++) $(OPTIONS) -L$(LINKPATH) -o $(<) $(>) $(LIBRARIES) -l$(FINDLIBS) } # Declare action for creating static libraries @@ -52,5 +79,5 @@ toolset.flags gcc.link-dll LIBRARIES ; actions link-dll bind LIBS { - g++ $(OPTIONS) -o $(<) -Wl,-soname,$(<[1]:D=) -shared $(>) $(LIBS) $(FINDLIBS) + $(NAME:E=g++) $(OPTIONS) -o $(<) -Wl,-soname,$(<[1]:D=) -shared $(>) $(LIBS) $(FINDLIBS) }