summaryrefslogtreecommitdiffstats
path: root/SCons/Action.py
diff options
context:
space:
mode:
Diffstat (limited to 'SCons/Action.py')
-rw-r--r--SCons/Action.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/SCons/Action.py b/SCons/Action.py
index 0849178..4dd0543 100644
--- a/SCons/Action.py
+++ b/SCons/Action.py
@@ -732,7 +732,7 @@ def _string_from_cmd_list(cmd_list):
default_ENV = None
-def get_default_ENV(env, target=None, source=None):
+def get_default_ENV(env):
"""
A fiddlin' little function that has an 'import SCons.Environment' which
can't be moved to the top level without creating an import loop. Since
@@ -755,6 +755,23 @@ def get_default_ENV(env, target=None, source=None):
return default_ENV
+def _resolve_shell_env(env, target, source):
+ ENV = get_default_ENV(env)
+ shell_gen = env.get('SHELL_ENV_GENERATORS')
+ if shell_gen is not None:
+ ENV = ENV.copy()
+ try:
+ shell_gens = iter(shell_gen)
+ except:
+ raise SCons.Errors.UserError("SHELL_ENV_GENERATORS must be iteratable.")
+ else:
+ for generator in shell_gens:
+ ENV = generator(env, target, source, ENV)
+ if not isinstance(ENV, dict):
+ raise SCons.Errors.UserError("SHELL_ENV_GENERATORS function: {generator} must return a dict.")
+ return ENV
+
+
def _subproc(scons_env, cmd, error='ignore', **kw):
"""Wrapper for subprocess which pulls from construction env.
@@ -924,10 +941,9 @@ class CommandAction(_ActionAction):
escape = env.get('ESCAPE', lambda x: x)
- ENV = env.get('SHELL_ENV_GENERATOR', get_default_ENV)(env, target, source)
+ ENV = _resolve_shell_env(env, target, source)
# Ensure that the ENV values are all strings:
-
for key, value in ENV.items():
if not is_String(value):
if is_List(value):