diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-21 10:38:22 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-03-21 10:38:22 +0200 |
commit | 903eeb2c681f2008602bf48265ec628e4fdc9225 (patch) | |
tree | f60cb2964320ba3ed64df8a49ffa89966533f8c8 /build2/utility.ixx | |
parent | fc8da2b2cc0a7ad497c810b54e53d68a11cb1887 (diff) |
Strip out_root when hashing linker input paths
This allows moving out_root of simple projects (no rpath, -I$out_root, or
similar) without causing a re-link which we use for testing.
Diffstat (limited to 'build2/utility.ixx')
-rw-r--r-- | build2/utility.ixx | 18 |
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) |