aboutsummaryrefslogtreecommitdiff
path: root/build/context.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build/context.cxx')
-rw-r--r--build/context.cxx19
1 files changed, 13 insertions, 6 deletions
diff --git a/build/context.cxx b/build/context.cxx
index 92f3db9..872a428 100644
--- a/build/context.cxx
+++ b/build/context.cxx
@@ -106,13 +106,20 @@ namespace build
return out_root / s.leaf (src_root);
}
+ const path* relative_base = &work;
+
path
- relative_work (const path& p)
+ relative (const path& p)
{
- if (p.sub (work))
- return p.leaf (work);
+ const path& b (*relative_base);
+
+ if (b.empty ())
+ return p;
+
+ if (p.sub (b))
+ return p.leaf (b);
- // If work is a sub-path of {src,out}_root and this path is also a
+ // If base is a sub-path of {src,out}_root and this path is also a
// sub-path of it, then use '..' to form a relative path.
//
// Don't think this is a good heuristic. For example, why shouldn't
@@ -125,9 +132,9 @@ namespace build
return p.relative (work);
*/
- if (p.root_directory () == work.root_directory ())
+ if (p.root_directory () == b.root_directory ())
{
- path r (p.relative (work));
+ path r (p.relative (b));
if (r.string ().size () < p.string ().size ())
return r;