From 903eeb2c681f2008602bf48265ec628e4fdc9225 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Mar 2018 10:38:22 +0200 Subject: 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. --- build2/utility.ixx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'build2/utility.ixx') 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 inline void append_options (cstrings& args, T& s, const variable& var, const char* e) -- cgit v1.1