2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 13:22:11 +00:00

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]
This commit is contained in:
Vladimir Prus
2002-12-02 07:20:37 +00:00
parent 075a9eaf97
commit a8d2feea84
6 changed files with 160 additions and 22 deletions

View File

@@ -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/<runtime-link>static
borland/<runtime-link>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 ;
}
}

View File

@@ -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 <toolset>gcc/<toolset-version>$(version) : $(name) ;
toolset.flags gcc.link NAME <toolset>gcc/<toolset-version>$(version) : $(name) ;
toolset.flags gcc.link-dll NAME <toolset>gcc/<toolset-version>$(version) : $(name) ;
# TODO: set path accordingly.
}
}
# Declare generators
generators.register-composing gcc.link : LIB OBJ : EXE : <toolset>gcc ;
@@ -22,7 +49,7 @@ toolset.flags gcc.compile INCLUDES <include> ;
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 <library> ;
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 <library> ;
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)
}

View File

@@ -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) ;
}
}
}

View File

@@ -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/<runtime-link>static
borland/<runtime-link>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 ;
}
}

View File

@@ -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) ;
}
}
}

View File

@@ -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 <toolset>gcc/<toolset-version>$(version) : $(name) ;
toolset.flags gcc.link NAME <toolset>gcc/<toolset-version>$(version) : $(name) ;
toolset.flags gcc.link-dll NAME <toolset>gcc/<toolset-version>$(version) : $(name) ;
# TODO: set path accordingly.
}
}
# Declare generators
generators.register-composing gcc.link : LIB OBJ : EXE : <toolset>gcc ;
@@ -22,7 +49,7 @@ toolset.flags gcc.compile INCLUDES <include> ;
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 <library> ;
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 <library> ;
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)
}