aboutsummaryrefslogtreecommitdiff
path: root/build2/utility.ixx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/utility.ixx')
-rw-r--r--build2/utility.ixx18
1 files changed, 18 insertions, 0 deletions
diff --git a/build2/utility.ixx b/build2/utility.ixx
index a726b0c..d0fe80c 100644
--- a/build2/utility.ixx
+++ b/build2/utility.ixx
@@ -33,6 +33,24 @@ namespace build2
return e - b;
}
+ inline void
+ hash_path (sha256& cs, const path& p, const dir_path& prefix)
+ {
+ // Note: for efficiency we don't use path::leaf() and "skip" the prefix
+ // without copying.
+ //
+ const char* s (p.string ().c_str ());
+
+ if (!prefix.empty () && p.sub (prefix))
+ {
+ s += prefix.size (); // Does not include trailing slash except for root.
+ if (path::traits::is_separator (*s))
+ ++s;
+ }
+
+ cs.append (s);
+ }
+
template <typename T>
inline void
append_options (cstrings& args, T& s, const variable& var, const char* e)