diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2022-05-09 22:13:56 (GMT) |
---|---|---|
committer | Daniel Moody <daniel.moody@mongodb.com> | 2022-05-09 22:13:56 (GMT) |
commit | cc811439cbb2a8b57d8626b1dec360ea37eb0ace (patch) | |
tree | d16b41e3965ee468f7ad917c0f9605702f3ce69a /SCons | |
parent | 9e579ada17bfecc4728a61ece53bfe8781652e5a (diff) | |
download | SCons-cc811439cbb2a8b57d8626b1dec360ea37eb0ace.zip SCons-cc811439cbb2a8b57d8626b1dec360ea37eb0ace.tar.gz SCons-cc811439cbb2a8b57d8626b1dec360ea37eb0ace.tar.bz2 |
added way for user to configure shell envronment before its executed.
Diffstat (limited to 'SCons')
-rw-r--r-- | SCons/Action.py | 16 | ||||
-rw-r--r-- | SCons/Action.xml | 22 |
2 files changed, 30 insertions, 8 deletions
diff --git a/SCons/Action.py b/SCons/Action.py index 81dc033..0110299 100644 --- a/SCons/Action.py +++ b/SCons/Action.py @@ -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,7 +924,7 @@ class CommandAction(_ActionAction): escape = env.get('ESCAPE', lambda x: x) - ENV = get_default_ENV(env) + ENV = env.get('SHELL_ENV_EXPANDER', get_default_ENV)(env) # Ensure that the ENV values are all strings: for key, value in ENV.items(): diff --git a/SCons/Action.xml b/SCons/Action.xml index 0e3ef33..69781b8 100644 --- a/SCons/Action.xml +++ b/SCons/Action.xml @@ -200,4 +200,26 @@ in which the command should be executed. </summary> </cvar> +<cvar name="SHELL_ENV_EXPANDER"> + <summary> + <para> +A function to obtain the environment dictionary which will be used +when executing the &cv-link-SPAWN; function. This primarily give the +user a chance to customize the shell 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): + </example_commands> + + <para> + <varname>env</varname> +The SCons construction environment from which the functionality +shell environment can be derived from. + </para> + </summary> +</cvar> + </sconsdoc> |