summaryrefslogtreecommitdiffstats
path: root/SCons
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2022-05-12 18:46:28 (GMT)
committerGitHub <noreply@github.com>2022-05-12 18:46:28 (GMT)
commit63c39b37c641f71bde1939bd4e4d22b7eecdb403 (patch)
tree0438489eccf9c675ffca9c54ddfc98a71e9b6086 /SCons
parent50df0c523b69b1ec832e1b39f6fd16fcd139f36e (diff)
parentfdae889759be56c6299bcedc577aecf2225f0190 (diff)
downloadSCons-63c39b37c641f71bde1939bd4e4d22b7eecdb403.zip
SCons-63c39b37c641f71bde1939bd4e4d22b7eecdb403.tar.gz
SCons-63c39b37c641f71bde1939bd4e4d22b7eecdb403.tar.bz2
Merge branch 'master' into ninja_always_execute
Diffstat (limited to 'SCons')
-rw-r--r--SCons/Action.py19
-rw-r--r--SCons/Action.xml30
2 files changed, 40 insertions, 9 deletions
diff --git a/SCons/Action.py b/SCons/Action.py
index 81dc033..0849178 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):
+def get_default_ENV(env, target=None, source=None):
"""
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
@@ -799,25 +799,25 @@ def _subproc(scons_env, cmd, error='ignore', **kw):
if error == 'raise': raise
# return a dummy Popen instance that only returns error
class dummyPopen:
- def __init__(self, e):
+ def __init__(self, e):
self.exception = e
# Add the following two to enable using the return value as a context manager
- # for example
+ # for example
# with Action._subproc(...) as po:
# logic here which uses po
- def __enter__(self):
+ def __enter__(self):
return self
- def __exit__(self, *args):
+ def __exit__(self, *args):
pass
- def communicate(self, input=None):
+ def communicate(self, input=None):
return ('', '')
- def wait(self):
+ def wait(self):
return -self.exception.errno
-
+
stdin = None
class f:
def read(self): return ''
@@ -924,9 +924,10 @@ class CommandAction(_ActionAction):
escape = env.get('ESCAPE', lambda x: x)
- ENV = get_default_ENV(env)
+ ENV = env.get('SHELL_ENV_GENERATOR', get_default_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):
diff --git a/SCons/Action.xml b/SCons/Action.xml
index 0e3ef33..2c18d55 100644
--- a/SCons/Action.xml
+++ b/SCons/Action.xml
@@ -200,4 +200,34 @@ in which the command should be executed.
</summary>
</cvar>
+<cvar name="SHELL_ENV_GENERATOR">
+ <summary>
+ <para>
+A function to generate or alter the environment dictionary which will be used
+when executing the &cv-link-SPAWN; function. This primarily give the
+user a chance to customize the execution environment for particular Actions.
+It must return a dictionary containing the environment variables as
+keys and the values as values.
+ </para>
+
+ <example_commands>
+def custom_shell_env(env, target, source):
+ </example_commands>
+
+ <para>
+ <varname>env</varname>
+The SCons construction environment from which the
+execution environment can be derived from.
+ </para>
+ <para>
+ <varname>target</varname>
+The list of targets associated with this action.
+ </para>
+ <para>
+ <varname>source</varname>
+The list of sources associated with this action.
+ </para>
+ </summary>
+</cvar>
+
</sconsdoc>