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

Add relative-to to calculate relative paths between dirs.

[SVN r17653]
This commit is contained in:
Rene Rivera
2003-02-26 06:12:24 +00:00
parent b52b8ca2e1
commit 64ebefbe29
2 changed files with 48 additions and 0 deletions

View File

@@ -327,6 +327,30 @@ rule relative ( child parent )
}
}
# Returns the minimal path to path2 that is relative path1.
#
rule relative-to ( path1 path2 )
{
local root_1 = [ regex.split [ reverse $(path1) ] / ] ;
local split1 = [ regex.split $(path1) / ] ;
local split2 = [ regex.split $(path2) / ] ;
while $(split1) && $(root_1)
{
if $(split1[1]) = $(split2[1])
{
root_1 = $(root_1[2-]) ;
split1 = $(split1[2-]) ;
split2 = $(split2[2-]) ;
}
else
{
split1 = ;
}
}
return [ join . $(root_1) $(split2) ] ;
}
rule make-NT ( native )

View File

@@ -327,6 +327,30 @@ rule relative ( child parent )
}
}
# Returns the minimal path to path2 that is relative path1.
#
rule relative-to ( path1 path2 )
{
local root_1 = [ regex.split [ reverse $(path1) ] / ] ;
local split1 = [ regex.split $(path1) / ] ;
local split2 = [ regex.split $(path2) / ] ;
while $(split1) && $(root_1)
{
if $(split1[1]) = $(split2[1])
{
root_1 = $(root_1[2-]) ;
split1 = $(split1[2-]) ;
split2 = $(split2[2-]) ;
}
else
{
split1 = ;
}
}
return [ join . $(root_1) $(split2) ] ;
}
rule make-NT ( native )