From c699c956d75dfaaded5bb24c5ea16edc73588649 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 27 Mar 2015 16:14:10 +0200 Subject: Rework dependency state dump support We now have a combined (scopes, variables, and targets) dump. --- build/context.cxx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'build/context.cxx') 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; -- cgit v1.1