mirror of
https://github.com/boostorg/build.git
synced 2026-02-20 14:42:14 +00:00
Fix subfeature validation
[SVN r16903]
This commit is contained in:
@@ -307,7 +307,7 @@ rule __test__ ( )
|
||||
try ;
|
||||
build-request.from-command-line bjam gcc/debug runtime-link=dynamic/static
|
||||
: $(test-space) ;
|
||||
catch "Invalid property 'static': 'static' is not a value of implicit feature." ;
|
||||
catch \"static\" is not a value of an implicit feature ;
|
||||
|
||||
|
||||
r = [ build-request.from-command-line bjam -d2 --debug debug target
|
||||
|
||||
@@ -136,10 +136,30 @@ rule values ( feature )
|
||||
return $($(feature).values) ;
|
||||
}
|
||||
|
||||
# returns true iff 'value' is a value of an implicit feature
|
||||
rule is-implicit-value ( value )
|
||||
# returns true iff 'value-string' is a value-string of an implicit feature
|
||||
rule is-implicit-value ( value-string )
|
||||
{
|
||||
if $(value) in $(.all-implicit-values)
|
||||
local v = [ regex.split $(value-string) - ] ;
|
||||
local failed ;
|
||||
if ! $(v[1]) in $(.all-implicit-values)
|
||||
{
|
||||
failed = true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
local feature = $($(v[1]).implicit-feature) ;
|
||||
|
||||
for local subvalue in $(v[2-])
|
||||
{
|
||||
ECHO subvalue= \"$(subvalue)\" ;
|
||||
if ! [ find-implied-subfeature $(feature) $(subvalue) : $(v[1]) ]
|
||||
{
|
||||
failed = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ! $(failed)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
@@ -148,10 +168,13 @@ rule is-implicit-value ( value )
|
||||
# return the implicit feature associated with the given implicit value.
|
||||
rule implied-feature ( implicit-value )
|
||||
{
|
||||
local feature = $($(implicit-value).implicit-feature) ;
|
||||
local components = [ regex.split $(implicit-value) "-" ] ;
|
||||
|
||||
local feature = $($(components[1]).implicit-feature) ;
|
||||
if ! $(feature)
|
||||
{
|
||||
error \"$(implicit-value)\" is not a value of an implicit feature ;
|
||||
feature = "" ;
|
||||
}
|
||||
return $(feature) ;
|
||||
}
|
||||
@@ -220,16 +243,17 @@ local rule expand-subfeatures-aux (
|
||||
validate-feature $(feature) ;
|
||||
}
|
||||
|
||||
local components = [ regex.split $(value) "-" ] ;
|
||||
if ! $(feature)
|
||||
{
|
||||
feature = [ implied-feature $(components[1]) ] ;
|
||||
feature = [ implied-feature $(value) ] ;
|
||||
}
|
||||
else if ! $(feature) in $(.all-features)
|
||||
{
|
||||
error unknown feature $(feature) ;
|
||||
}
|
||||
|
||||
local components = [ regex.split $(value) "-" ] ;
|
||||
|
||||
# get the top-level feature's value
|
||||
local value = $(components[1]:G=) ;
|
||||
|
||||
@@ -305,26 +329,31 @@ local rule extend-feature ( feature : values * )
|
||||
}
|
||||
|
||||
# Checks that value-string is a valid value-string for the given feature.
|
||||
local rule validate-value-string ( feature value-string )
|
||||
rule validate-value-string ( feature value-string )
|
||||
{
|
||||
feature = [ grist $(feature) ] ;
|
||||
|
||||
local values = $(value-string) ;
|
||||
if $($(feature).subfeatures)
|
||||
|
||||
if ! ( $(values) in $(feature).values )
|
||||
{
|
||||
values = [ regex.split $(value-string) - ] ;
|
||||
}
|
||||
if $($(feature).subfeatures)
|
||||
{
|
||||
values = [ regex.split $(value-string) - ] ;
|
||||
}
|
||||
|
||||
if ! ( $(values[1]) in $($(feature).values) )
|
||||
{
|
||||
return \"$(values[1])\" is not a known value of feature $(feature) ;
|
||||
}
|
||||
if ! ( $(values[1]) in $($(feature).values) )
|
||||
{
|
||||
error \"$(values[1])\" is not a known value of feature $(feature) ;
|
||||
}
|
||||
|
||||
if $(values[2])
|
||||
{
|
||||
# this will validate any subfeature values in value-string
|
||||
implied-subfeature $(feature) [ sequence.join $(values[2-]) - ]
|
||||
: $(values[1]) ;
|
||||
if $(values[2])
|
||||
{
|
||||
# this will validate any subfeature values in value-string
|
||||
implied-subfeature $(feature) [ sequence.join $(values[2-]) : - ]
|
||||
: $(values[1]) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Extends the given subfeature with the subvalues. If the optional
|
||||
@@ -876,6 +905,15 @@ local rule __test__ ( )
|
||||
}
|
||||
catch unknown feature ;
|
||||
|
||||
validate-value-string <toolset> gcc ;
|
||||
validate-value-string <toolset> gcc-3.0.1 ;
|
||||
|
||||
try ;
|
||||
{
|
||||
validate-value-string <toolset> digital_mars ;
|
||||
}
|
||||
catch \"digital_mars\" is not a known value of <toolset> ;
|
||||
|
||||
try ;
|
||||
{
|
||||
feature foobar : : baz ;
|
||||
|
||||
@@ -31,9 +31,9 @@ rule init ( a1 * : a2 * : a3 * )
|
||||
|
||||
# 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) ;
|
||||
toolset.flags gcc.compile NAME <toolset>gcc-$(version) : $(name) ;
|
||||
toolset.flags gcc.link NAME <toolset>gcc-$(version) : $(name) ;
|
||||
toolset.flags gcc.link-dll NAME <toolset>gcc-$(version) : $(name) ;
|
||||
|
||||
# TODO: set path accordingly.
|
||||
}
|
||||
|
||||
@@ -201,10 +201,9 @@ rule validate ( property : feature-space ? )
|
||||
{
|
||||
msg = "unknown feature '$(feature)'" ;
|
||||
}
|
||||
else if $(value) && ! $(value) in [ $(feature-space).values $(feature) ]
|
||||
&& ! free in [ $(feature-space).attributes $(feature) ]
|
||||
else if $(value) && ! free in [ $(feature-space).attributes $(feature) ]
|
||||
{
|
||||
msg = "value '"$(value:J=" ")"' is not valid for feature'"$(feature)' ;
|
||||
$(feature-space).validate-value-string $(feature) $(value) ;
|
||||
}
|
||||
else if ! $(value)
|
||||
{
|
||||
@@ -213,10 +212,8 @@ rule validate ( property : feature-space ? )
|
||||
}
|
||||
else
|
||||
{
|
||||
if ! [ $(feature-space).is-implicit-value $(property) ]
|
||||
{
|
||||
msg = '$(property:J=" ")' "is not a value of implicit feature" ;
|
||||
}
|
||||
local feature = [ $(feature-space).implied-feature $(property) ] ;
|
||||
$(feature-space).validate-value-string $(feature) $(property) ;
|
||||
}
|
||||
if $(msg)
|
||||
{
|
||||
@@ -389,6 +386,8 @@ local rule __test__ ( )
|
||||
import assert ;
|
||||
|
||||
feature toolset : gcc : implicit ;
|
||||
subfeature toolset gcc : version : 2.95.2 2.95.3 2.95.4
|
||||
3.0 3.0.1 3.0.2 : optional ;
|
||||
feature define : : free ;
|
||||
feature runtime-link : dynamic static : symmetric link-incompatible ;
|
||||
feature optimization : on off ;
|
||||
@@ -400,6 +399,11 @@ local rule __test__ ( )
|
||||
|
||||
}
|
||||
|
||||
validate gcc : $(test-space) ;
|
||||
validate gcc-3.0.1 : $(test-space) ;
|
||||
validate <toolset>gcc : $(test-space) ;
|
||||
validate <toolset>gcc-3.0.1 : $(test-space) ;
|
||||
|
||||
assert.result <toolset>gcc <rtti>off <define>FOO
|
||||
: refine <toolset>gcc <rtti>off
|
||||
: <define>FOO
|
||||
@@ -447,7 +451,7 @@ local rule __test__ ( )
|
||||
|
||||
try ;
|
||||
validate <rtti>default : $(test-space) ;
|
||||
catch "Invalid property '<rtti>default': value 'default' is not valid for feature'rtti'." ;
|
||||
catch \"default\" is not a known value of feature <rtti> ;
|
||||
|
||||
validate <define>WHATEVER : $(test-space) ;
|
||||
|
||||
@@ -457,7 +461,7 @@ local rule __test__ ( )
|
||||
|
||||
try ;
|
||||
validate value : $(test-space) ;
|
||||
catch "Invalid property 'value': 'value' is not a value of implicit feature." ;
|
||||
catch "value" is not a value of an implicit feature ;
|
||||
|
||||
|
||||
assert.result <rtti>on
|
||||
|
||||
@@ -259,6 +259,7 @@ local rule __test__ ( )
|
||||
|
||||
assert.result foo-bar-baz : sequence.join foo bar baz : - ;
|
||||
assert.result substandard : sequence.join sub stan dard ;
|
||||
assert.result 3.0.1 : sequence.join 3.0.1 : - ;
|
||||
|
||||
assert.result 0 : sequence.length ;
|
||||
assert.result 3 : sequence.length a b c ;
|
||||
|
||||
@@ -307,7 +307,7 @@ rule __test__ ( )
|
||||
try ;
|
||||
build-request.from-command-line bjam gcc/debug runtime-link=dynamic/static
|
||||
: $(test-space) ;
|
||||
catch "Invalid property 'static': 'static' is not a value of implicit feature." ;
|
||||
catch \"static\" is not a value of an implicit feature ;
|
||||
|
||||
|
||||
r = [ build-request.from-command-line bjam -d2 --debug debug target
|
||||
|
||||
@@ -136,10 +136,30 @@ rule values ( feature )
|
||||
return $($(feature).values) ;
|
||||
}
|
||||
|
||||
# returns true iff 'value' is a value of an implicit feature
|
||||
rule is-implicit-value ( value )
|
||||
# returns true iff 'value-string' is a value-string of an implicit feature
|
||||
rule is-implicit-value ( value-string )
|
||||
{
|
||||
if $(value) in $(.all-implicit-values)
|
||||
local v = [ regex.split $(value-string) - ] ;
|
||||
local failed ;
|
||||
if ! $(v[1]) in $(.all-implicit-values)
|
||||
{
|
||||
failed = true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
local feature = $($(v[1]).implicit-feature) ;
|
||||
|
||||
for local subvalue in $(v[2-])
|
||||
{
|
||||
ECHO subvalue= \"$(subvalue)\" ;
|
||||
if ! [ find-implied-subfeature $(feature) $(subvalue) : $(v[1]) ]
|
||||
{
|
||||
failed = true ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ! $(failed)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
@@ -148,10 +168,13 @@ rule is-implicit-value ( value )
|
||||
# return the implicit feature associated with the given implicit value.
|
||||
rule implied-feature ( implicit-value )
|
||||
{
|
||||
local feature = $($(implicit-value).implicit-feature) ;
|
||||
local components = [ regex.split $(implicit-value) "-" ] ;
|
||||
|
||||
local feature = $($(components[1]).implicit-feature) ;
|
||||
if ! $(feature)
|
||||
{
|
||||
error \"$(implicit-value)\" is not a value of an implicit feature ;
|
||||
feature = "" ;
|
||||
}
|
||||
return $(feature) ;
|
||||
}
|
||||
@@ -220,16 +243,17 @@ local rule expand-subfeatures-aux (
|
||||
validate-feature $(feature) ;
|
||||
}
|
||||
|
||||
local components = [ regex.split $(value) "-" ] ;
|
||||
if ! $(feature)
|
||||
{
|
||||
feature = [ implied-feature $(components[1]) ] ;
|
||||
feature = [ implied-feature $(value) ] ;
|
||||
}
|
||||
else if ! $(feature) in $(.all-features)
|
||||
{
|
||||
error unknown feature $(feature) ;
|
||||
}
|
||||
|
||||
local components = [ regex.split $(value) "-" ] ;
|
||||
|
||||
# get the top-level feature's value
|
||||
local value = $(components[1]:G=) ;
|
||||
|
||||
@@ -305,26 +329,31 @@ local rule extend-feature ( feature : values * )
|
||||
}
|
||||
|
||||
# Checks that value-string is a valid value-string for the given feature.
|
||||
local rule validate-value-string ( feature value-string )
|
||||
rule validate-value-string ( feature value-string )
|
||||
{
|
||||
feature = [ grist $(feature) ] ;
|
||||
|
||||
local values = $(value-string) ;
|
||||
if $($(feature).subfeatures)
|
||||
|
||||
if ! ( $(values) in $(feature).values )
|
||||
{
|
||||
values = [ regex.split $(value-string) - ] ;
|
||||
}
|
||||
if $($(feature).subfeatures)
|
||||
{
|
||||
values = [ regex.split $(value-string) - ] ;
|
||||
}
|
||||
|
||||
if ! ( $(values[1]) in $($(feature).values) )
|
||||
{
|
||||
return \"$(values[1])\" is not a known value of feature $(feature) ;
|
||||
}
|
||||
if ! ( $(values[1]) in $($(feature).values) )
|
||||
{
|
||||
error \"$(values[1])\" is not a known value of feature $(feature) ;
|
||||
}
|
||||
|
||||
if $(values[2])
|
||||
{
|
||||
# this will validate any subfeature values in value-string
|
||||
implied-subfeature $(feature) [ sequence.join $(values[2-]) - ]
|
||||
: $(values[1]) ;
|
||||
if $(values[2])
|
||||
{
|
||||
# this will validate any subfeature values in value-string
|
||||
implied-subfeature $(feature) [ sequence.join $(values[2-]) : - ]
|
||||
: $(values[1]) ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Extends the given subfeature with the subvalues. If the optional
|
||||
@@ -876,6 +905,15 @@ local rule __test__ ( )
|
||||
}
|
||||
catch unknown feature ;
|
||||
|
||||
validate-value-string <toolset> gcc ;
|
||||
validate-value-string <toolset> gcc-3.0.1 ;
|
||||
|
||||
try ;
|
||||
{
|
||||
validate-value-string <toolset> digital_mars ;
|
||||
}
|
||||
catch \"digital_mars\" is not a known value of <toolset> ;
|
||||
|
||||
try ;
|
||||
{
|
||||
feature foobar : : baz ;
|
||||
|
||||
@@ -201,10 +201,9 @@ rule validate ( property : feature-space ? )
|
||||
{
|
||||
msg = "unknown feature '$(feature)'" ;
|
||||
}
|
||||
else if $(value) && ! $(value) in [ $(feature-space).values $(feature) ]
|
||||
&& ! free in [ $(feature-space).attributes $(feature) ]
|
||||
else if $(value) && ! free in [ $(feature-space).attributes $(feature) ]
|
||||
{
|
||||
msg = "value '"$(value:J=" ")"' is not valid for feature'"$(feature)' ;
|
||||
$(feature-space).validate-value-string $(feature) $(value) ;
|
||||
}
|
||||
else if ! $(value)
|
||||
{
|
||||
@@ -213,10 +212,8 @@ rule validate ( property : feature-space ? )
|
||||
}
|
||||
else
|
||||
{
|
||||
if ! [ $(feature-space).is-implicit-value $(property) ]
|
||||
{
|
||||
msg = '$(property:J=" ")' "is not a value of implicit feature" ;
|
||||
}
|
||||
local feature = [ $(feature-space).implied-feature $(property) ] ;
|
||||
$(feature-space).validate-value-string $(feature) $(property) ;
|
||||
}
|
||||
if $(msg)
|
||||
{
|
||||
@@ -389,6 +386,8 @@ local rule __test__ ( )
|
||||
import assert ;
|
||||
|
||||
feature toolset : gcc : implicit ;
|
||||
subfeature toolset gcc : version : 2.95.2 2.95.3 2.95.4
|
||||
3.0 3.0.1 3.0.2 : optional ;
|
||||
feature define : : free ;
|
||||
feature runtime-link : dynamic static : symmetric link-incompatible ;
|
||||
feature optimization : on off ;
|
||||
@@ -400,6 +399,11 @@ local rule __test__ ( )
|
||||
|
||||
}
|
||||
|
||||
validate gcc : $(test-space) ;
|
||||
validate gcc-3.0.1 : $(test-space) ;
|
||||
validate <toolset>gcc : $(test-space) ;
|
||||
validate <toolset>gcc-3.0.1 : $(test-space) ;
|
||||
|
||||
assert.result <toolset>gcc <rtti>off <define>FOO
|
||||
: refine <toolset>gcc <rtti>off
|
||||
: <define>FOO
|
||||
@@ -447,7 +451,7 @@ local rule __test__ ( )
|
||||
|
||||
try ;
|
||||
validate <rtti>default : $(test-space) ;
|
||||
catch "Invalid property '<rtti>default': value 'default' is not valid for feature'rtti'." ;
|
||||
catch \"default\" is not a known value of feature <rtti> ;
|
||||
|
||||
validate <define>WHATEVER : $(test-space) ;
|
||||
|
||||
@@ -457,7 +461,7 @@ local rule __test__ ( )
|
||||
|
||||
try ;
|
||||
validate value : $(test-space) ;
|
||||
catch "Invalid property 'value': 'value' is not a value of implicit feature." ;
|
||||
catch "value" is not a value of an implicit feature ;
|
||||
|
||||
|
||||
assert.result <rtti>on
|
||||
|
||||
@@ -31,9 +31,9 @@ rule init ( a1 * : a2 * : a3 * )
|
||||
|
||||
# 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) ;
|
||||
toolset.flags gcc.compile NAME <toolset>gcc-$(version) : $(name) ;
|
||||
toolset.flags gcc.link NAME <toolset>gcc-$(version) : $(name) ;
|
||||
toolset.flags gcc.link-dll NAME <toolset>gcc-$(version) : $(name) ;
|
||||
|
||||
# TODO: set path accordingly.
|
||||
}
|
||||
|
||||
@@ -259,6 +259,7 @@ local rule __test__ ( )
|
||||
|
||||
assert.result foo-bar-baz : sequence.join foo bar baz : - ;
|
||||
assert.result substandard : sequence.join sub stan dard ;
|
||||
assert.result 3.0.1 : sequence.join 3.0.1 : - ;
|
||||
|
||||
assert.result 0 : sequence.length ;
|
||||
assert.result 3 : sequence.length a b c ;
|
||||
|
||||
Reference in New Issue
Block a user