From b3bc26dc284cf73e97b88c9979d49368d07e686c Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 Mar 2021 16:03:29 +0200 Subject: Add support for propagating project environment --- libbuild2/scope.hxx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'libbuild2/scope.hxx') diff --git a/libbuild2/scope.hxx b/libbuild2/scope.hxx index b8ee15a..9f88dc9 100644 --- a/libbuild2/scope.hxx +++ b/libbuild2/scope.hxx @@ -488,6 +488,19 @@ namespace build2 // Target types. // target_type_map target_types; + + // Environment variable overrides. + // + // These overrides should be applied to the environment when running + // tools (e.g., compilers) or querying environment variables from the + // buildfiles and by the build system itself. Populated by the config + // module and is not available during bootstrap (more precisely, not + // available until before_first modules have been initialized). The list + // is either empty of NULL-terminated. + // + // See also auto_project_env below. + // + vector environment; }; unique_ptr root_extra; @@ -575,6 +588,23 @@ namespace build2 return to_stream (os, s.out_path (), true /* representation */); } + // Automatic project environment setup/cleanup. + // + struct auto_project_env: auto_thread_env + { + auto_project_env () = default; + + explicit + auto_project_env (nullptr_t p) // Clear current environment. + : auto_thread_env (p) {} + + explicit + auto_project_env (const scope& rs) + : auto_thread_env (rs.root_extra->environment.empty () + ? nullptr + : rs.root_extra->environment.data ()) {} + }; + // Return the src/out directory corresponding to the given out/src. The // passed directory should be a sub-directory of out/src_root. // -- cgit v1.1