aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/install/utility.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/install/utility.hxx')
-rw-r--r--libbuild2/install/utility.hxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/libbuild2/install/utility.hxx b/libbuild2/install/utility.hxx
index 530a9d7..7ab8114 100644
--- a/libbuild2/install/utility.hxx
+++ b/libbuild2/install/utility.hxx
@@ -86,6 +86,18 @@ namespace build2
//
LIBBUILD2_SYMEXPORT path
resolve_file (const file&); // rule.cxx
+
+ // Given an abolute path return its chroot'ed version, if any, accoring to
+ // install.chroot.
+ //
+ template <typename P>
+ inline P
+ chroot_path (const scope& rs, const P& p)
+ {
+ assert (p.absolute ());
+ const dir_path* d (cast_null<dir_path> (rs["install.chroot"]));
+ return d != nullptr ? *d / p.leaf (p.root_directory ()) : p;
+ }
}
}