From 1ac5458eede2b4b2d3bc98cde787348f70328361 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Apr 2021 10:35:13 +0200 Subject: Add another hash/save_environment() overload --- libbuild2/cc/guess.cxx | 4 ++-- libbuild2/config/utility.hxx | 10 ++++++++++ libbuild2/utility.hxx | 6 ++++++ libbuild2/utility.ixx | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/cc/guess.cxx b/libbuild2/cc/guess.cxx index 82be591..839bf20 100644 --- a/libbuild2/cc/guess.cxx +++ b/libbuild2/cc/guess.cxx @@ -1812,7 +1812,7 @@ namespace build2 // See "Environment Variables Affecting GCC". // - // @@ TODO: Yt feels like we should unset the following variables: + // @@ TODO: It feels like we should unset the following variables: // // DEPENDENCIES_OUTPUT // SUNPRO_DEPENDENCIES @@ -1835,7 +1835,7 @@ namespace build2 nullptr}; // Note that Clang recognizes a whole family of *_DEPLOYMENT_TARGET - // variables. + // variables (as does ld64). // static const char* macos_env[] = { "SDKROOT", "MACOSX_DEPLOYMENT_TARGET", nullptr}; diff --git a/libbuild2/config/utility.hxx b/libbuild2/config/utility.hxx index 8dc0650..4673d0c 100644 --- a/libbuild2/config/utility.hxx +++ b/libbuild2/config/utility.hxx @@ -139,6 +139,16 @@ namespace build2 } inline void + save_environment (scope& rs, const cstrings& vars) + { + if (config_save_environment != nullptr) + { + for (const char* var: vars) + config_save_environment (rs, var); + } + } + + inline void save_environment (scope& rs, const strings& vars) { if (config_save_environment != nullptr) diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index b4a8ce4..c3e1921 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -818,6 +818,12 @@ namespace build2 hash_environment (initializer_list names); void + hash_environment (sha256&, const cstrings& names); + + string + hash_environment (const cstrings& names); + + void hash_environment (sha256&, const strings& names); string diff --git a/libbuild2/utility.ixx b/libbuild2/utility.ixx index 3f9d34b..aedfc94 100644 --- a/libbuild2/utility.ixx +++ b/libbuild2/utility.ixx @@ -274,6 +274,21 @@ namespace build2 } inline void + hash_environment (sha256& cs, const cstrings& ns) + { + for (const char* n: ns) + hash_environment (cs, n); + } + + inline string + hash_environment (const cstrings& ns) + { + sha256 cs; + hash_environment (cs, ns); + return cs.string (); + } + + inline void hash_environment (sha256& cs, const strings& ns) { for (const string& n: ns) -- cgit v1.1