aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/utility.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-04-20 11:19:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-04-20 11:26:05 +0200
commit0353b231d51ab7ea5ead98ac838e7c2ba1b0df89 (patch)
treec5b0794512587a1062de97153df6f0b236f928d3 /libbuild2/utility.ixx
parent834152a6e3f3e8459b53e49370bfdd82685a700d (diff)
Track changes to environment in cc rules
Diffstat (limited to 'libbuild2/utility.ixx')
-rw-r--r--libbuild2/utility.ixx67
1 files changed, 67 insertions, 0 deletions
diff --git a/libbuild2/utility.ixx b/libbuild2/utility.ixx
index 9a77fae..3f9d34b 100644
--- a/libbuild2/utility.ixx
+++ b/libbuild2/utility.ixx
@@ -241,6 +241,73 @@ namespace build2
return find_option_prefixes (ps, s[var], ic);
}
+ // hash_environment()
+ //
+ inline void
+ hash_environment (sha256& cs, const char* n)
+ {
+ cs.append (n);
+
+ if (optional<string> v = getenv (n))
+ cs.append (*v);
+ }
+
+ inline void
+ hash_environment (sha256& cs, const string& n)
+ {
+ hash_environment (cs, n.c_str ());
+ }
+
+ inline void
+ hash_environment (sha256& cs, initializer_list<const char*> ns)
+ {
+ for (const char* n: ns)
+ hash_environment (cs, n);
+ }
+
+ inline string
+ hash_environment (initializer_list<const char*> ns)
+ {
+ sha256 cs;
+ hash_environment (cs, ns);
+ return cs.string ();
+ }
+
+ inline void
+ hash_environment (sha256& cs, const strings& ns)
+ {
+ for (const string& n: ns)
+ hash_environment (cs, n);
+ }
+
+ inline string
+ hash_environment (const strings& ns)
+ {
+ sha256 cs;
+ hash_environment (cs, ns);
+ return cs.string ();
+ }
+
+ inline void
+ hash_environment (sha256& cs, const char* const* ns)
+ {
+ if (ns != nullptr)
+ {
+ for (; *ns != nullptr; ++ns)
+ hash_environment (cs, *ns);
+ }
+ }
+
+ inline string
+ hash_environment (const char* const* ns)
+ {
+ sha256 cs;
+ hash_environment (cs, ns);
+ return cs.string ();
+ }
+
+ // find_stem()
+ //
inline size_t
find_stem (const string& s, size_t s_p, size_t s_n,
const char* stem, const char* seps)