diff options
| author | Steven Knight <knight@baldmt.com> | 2002-04-22 19:21:26 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2002-04-22 19:21:26 (GMT) |
| commit | 74f98d3083cfbb859bf032dba37ed14bbb5219dd (patch) | |
| tree | 331e7f6b4cb4d8ec98a4cce203ab22f4ba893f9b /src/engine/SCons/Action.py | |
| parent | 9afa958bb1b299c47b3197589ab7b9b89686cc6b (diff) | |
| download | SCons-74f98d3083cfbb859bf032dba37ed14bbb5219dd.zip SCons-74f98d3083cfbb859bf032dba37ed14bbb5219dd.tar.gz SCons-74f98d3083cfbb859bf032dba37ed14bbb5219dd.tar.bz2 | |
Several bug fixes from Charles Crain.
Diffstat (limited to 'src/engine/SCons/Action.py')
| -rw-r--r-- | src/engine/SCons/Action.py | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/engine/SCons/Action.py b/src/engine/SCons/Action.py index 38b5413..1941e1a 100644 --- a/src/engine/SCons/Action.py +++ b/src/engine/SCons/Action.py @@ -198,6 +198,15 @@ def _do_create_action(act): elif callable(act): return FunctionAction(act) elif SCons.Util.is_String(act): + var=SCons.Util.get_environment_var(act) + if var: + # This looks like a string that is purely an Environment + # variable reference, like "$FOO" or "${FOO}". We do + # something special here...we lazily evaluate the contents + # of that Environment variable, so a user could but something + # like a function or a CommandGenerator in that variable + # instead of a string. + return CommandGeneratorAction(LazyCmdGenerator(var)) listCmds = map(lambda x: CommandAction(string.split(x)), string.split(act, '\n')) if len(listCmds) == 1: @@ -314,11 +323,19 @@ class EnvDictProxy(UserDict.UserDict): def __init__(self, env): UserDict.UserDict.__init__(self, env) - def subst(self, string): - return SCons.Util.scons_subst(string, self.data, {}, _rm) + def subst(self, string, raw=0): + if raw: + regex_remove = None + else: + regex_remove = _rm + return SCons.Util.scons_subst(string, self.data, {}, regex_remove) - def subst_list(self, string): - return SCons.Util.scons_subst_list(string, self.data, {}, _rm) + def subst_list(self, string, raw=0): + if raw: + regex_remove = None + else: + regex_remove = _rm + return SCons.Util.scons_subst_list(string, self.data, {}, regex_remove) class CommandAction(ActionBase): """Class for command-execution actions.""" @@ -410,6 +427,21 @@ class CommandGeneratorAction(ActionBase): """ return apply(self.__generate(kw).get_contents, (), kw) +class LazyCmdGenerator: + """This is a simple callable class that acts as a command generator. + It holds on to a key into an Environment dictionary, then waits + until execution time to see what type it is, then tries to + create an Action out of it.""" + def __init__(self, var): + self.var = SCons.Util.to_String(var) + + def __call__(self, env, **kw): + if env.has_key(self.var): + return env[self.var] + else: + # The variable reference substitutes to nothing. + return '' + class FunctionAction(ActionBase): """Class for Python function actions.""" def __init__(self, function): |
