aboutsummaryrefslogtreecommitdiff
path: root/build2/utility.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-13 18:20:35 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 08:12:47 +0200
commitae579402c8c64ea8ceea2e9fcee5097b3c53e353 (patch)
tree5933a00f434adab5583e81c147754d5d4dc69f12 /build2/utility.txx
parent8d2e541ab1aa24140eb680fb046e49a4a3f0bbd2 (diff)
Minor dependency cleanup
Diffstat (limited to 'build2/utility.txx')
-rw-r--r--build2/utility.txx25
1 files changed, 25 insertions, 0 deletions
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 <typename K>
+ basic_path<char, K>
+ relative (const basic_path<char, K>& p)
+ {
+ typedef basic_path<char, K> 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 <typename T>
T
run (const process_path& pp,