From ae579402c8c64ea8ceea2e9fcee5097b3c53e353 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 13 Oct 2016 18:20:35 +0200 Subject: Minor dependency cleanup --- build2/utility.txx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'build2/utility.txx') diff --git a/build2/utility.txx b/build2/utility.txx index 1c710ee..bba66d6 100644 --- a/build2/utility.txx +++ b/build2/utility.txx @@ -4,6 +4,31 @@ namespace build2 { + template + basic_path + relative (const basic_path& p) + { + typedef basic_path path; + + const dir_path& b (*relative_base); + + if (p.simple () || b.empty ()) + return p; + + if (p.sub (b)) + return p.leaf (b); + + if (p.root_directory () == b.root_directory ()) + { + path r (p.relative (b)); + + if (r.string ().size () < p.string ().size ()) + return r; + } + + return p; + } + template T run (const process_path& pp, -- cgit v1.1