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

Tweak path-constant handling.

* new/path.jam (make-UNIX, make-NT): Call 'path.join' on elements,
        so that paths are normilazed.
      (join): Allow one element to be passed.
    * new/project-root.jam: Use 'path.root' when declaring path constants.


[SVN r16096]
This commit is contained in:
Vladimir Prus
2002-11-04 17:27:42 +00:00
parent f9bf8ef5e2
commit fbf32855f5
4 changed files with 50 additions and 26 deletions

View File

@@ -197,14 +197,21 @@ local rule join-imp ( elements + )
#
rule join ( elements + )
{
for local e in $(elements[2-])
if ! $(elements[2])
{
if [ is-rooted $(e) ]
{
error only first element may be rooted ;
}
return $(elements[1]) ;
}
return [ join-imp $(elements) ] ;
else
{
for local e in $(elements[2-])
{
if [ is-rooted $(e) ]
{
error only first element may be rooted ;
}
}
return [ join-imp $(elements) ] ;
}
}
@@ -301,7 +308,7 @@ rule make-NT ( native )
tokens = $(tokens[1--2]) ; # discard the empty element
}
result = [ sequence.join $(tokens) : "/" ] ;
result = [ path.join $(tokens) ] ;
if [ regex.match "(^.:)" : $(native) ]
{
@@ -319,7 +326,7 @@ rule native-NT ( path )
rule make-UNIX ( native )
{
return $(native) ;
return [ path.join [ regex.split $(native) "/" ] ] ;
}
rule native-UNIX ( path )
@@ -366,6 +373,7 @@ rule __test__ ( ) {
assert.result ".." : reverse "foo" ;
assert.result "../../.." : reverse "foo/bar/giz" ;
assert.result "foo" : join "foo" ;
assert.result "/foo" : join "/" "foo" ;
assert.result "foo/bar" : join "foo" "bar" ;
assert.result "foo/bar" : join "foo/giz" "../bar" ;
@@ -404,8 +412,10 @@ rule __test__ ( ) {
assert.result "foo/bar/giz" : make "foo/bar/giz" ;
assert.result "foo/bar/giz" : make "foo\\bar\\giz" ;
assert.result "foo" : make "foo/." ;
assert.result "foo" : make "foo/bar/.." ;
assert.result "/D:/My Documents" : make "D:\\My Documents" ;
assert.result "/c:/boost/tools/build/test/../new/project.jam" : make "c:\\boost\\tools\\build\\test\\..\\new\\project.jam" ;
assert.result "/c:/boost/tools/build/new/project.jam" : make "c:\\boost\\tools\\build\\test\\..\\new\\project.jam" ;
assert.result "foo\\bar\\giz" : native "foo/bar/giz" ;
assert.result "foo" : native "foo" ;
@@ -414,6 +424,11 @@ rule __test__ ( ) {
local os = UNIX ;
assert.result "foo/bar/giz" : make "foo/bar/giz" ;
assert.result "/sub1" : make "/sub1/." ;
assert.result "/sub1" : make "/sub1/sub2/.." ;
assert.result "sub1" : make "sub1/." ;
assert.result "sub1" : make "sub1/sub2/.." ;
assert.result "/foo/bar" : native "/foo/bar" ;
}

View File

@@ -152,10 +152,7 @@ rule project-root-object (
switch $(type)
{
case path :
if ! [ path.is-rooted $(value) ]
{
value = [ path.join [ regex.split $(self.location)/$(value) "/" ] ] ;
}
value = [ path.root [ path.native $(value) ] $(self.location) ] ;
}
if ! $(name) in $(self.constants)
{

View File

@@ -152,10 +152,7 @@ rule project-root-object (
switch $(type)
{
case path :
if ! [ path.is-rooted $(value) ]
{
value = [ path.join [ regex.split $(self.location)/$(value) "/" ] ] ;
}
value = [ path.root [ path.native $(value) ] $(self.location) ] ;
}
if ! $(name) in $(self.constants)
{

View File

@@ -197,14 +197,21 @@ local rule join-imp ( elements + )
#
rule join ( elements + )
{
for local e in $(elements[2-])
if ! $(elements[2])
{
if [ is-rooted $(e) ]
{
error only first element may be rooted ;
}
return $(elements[1]) ;
}
return [ join-imp $(elements) ] ;
else
{
for local e in $(elements[2-])
{
if [ is-rooted $(e) ]
{
error only first element may be rooted ;
}
}
return [ join-imp $(elements) ] ;
}
}
@@ -301,7 +308,7 @@ rule make-NT ( native )
tokens = $(tokens[1--2]) ; # discard the empty element
}
result = [ sequence.join $(tokens) : "/" ] ;
result = [ path.join $(tokens) ] ;
if [ regex.match "(^.:)" : $(native) ]
{
@@ -319,7 +326,7 @@ rule native-NT ( path )
rule make-UNIX ( native )
{
return $(native) ;
return [ path.join [ regex.split $(native) "/" ] ] ;
}
rule native-UNIX ( path )
@@ -366,6 +373,7 @@ rule __test__ ( ) {
assert.result ".." : reverse "foo" ;
assert.result "../../.." : reverse "foo/bar/giz" ;
assert.result "foo" : join "foo" ;
assert.result "/foo" : join "/" "foo" ;
assert.result "foo/bar" : join "foo" "bar" ;
assert.result "foo/bar" : join "foo/giz" "../bar" ;
@@ -404,8 +412,10 @@ rule __test__ ( ) {
assert.result "foo/bar/giz" : make "foo/bar/giz" ;
assert.result "foo/bar/giz" : make "foo\\bar\\giz" ;
assert.result "foo" : make "foo/." ;
assert.result "foo" : make "foo/bar/.." ;
assert.result "/D:/My Documents" : make "D:\\My Documents" ;
assert.result "/c:/boost/tools/build/test/../new/project.jam" : make "c:\\boost\\tools\\build\\test\\..\\new\\project.jam" ;
assert.result "/c:/boost/tools/build/new/project.jam" : make "c:\\boost\\tools\\build\\test\\..\\new\\project.jam" ;
assert.result "foo\\bar\\giz" : native "foo/bar/giz" ;
assert.result "foo" : native "foo" ;
@@ -414,6 +424,11 @@ rule __test__ ( ) {
local os = UNIX ;
assert.result "foo/bar/giz" : make "foo/bar/giz" ;
assert.result "/sub1" : make "/sub1/." ;
assert.result "/sub1" : make "/sub1/sub2/.." ;
assert.result "sub1" : make "sub1/." ;
assert.result "sub1" : make "sub1/sub2/.." ;
assert.result "/foo/bar" : native "/foo/bar" ;
}