diff options
author | Steven Knight <knight@baldmt.com> | 2004-03-12 13:24:18 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-03-12 13:24:18 (GMT) |
commit | 7f0857e23182eb4fba10dc65216c65dbe7ee13da (patch) | |
tree | ce7ad48e3d0e7cd9708904c8ceedad4da4125090 /src/engine | |
parent | 503c526b323d74874ee99ae5d54b30f45046ce00 (diff) | |
download | SCons-7f0857e23182eb4fba10dc65216c65dbe7ee13da.zip SCons-7f0857e23182eb4fba10dc65216c65dbe7ee13da.tar.gz SCons-7f0857e23182eb4fba10dc65216c65dbe7ee13da.tar.bz2 |
Add an Execute() method.
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/Environment.py | 6 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/Script/SConscript.py | 3 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index da455bc..ca25021 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -920,6 +920,12 @@ class Base: def Environment(self, **kw): return apply(SCons.Environment.Environment, [], self.subst_kw(kw)) + def Execute(self, action, *args, **kw): + """Directly execute an action through an Environment + """ + action = apply(self.Action, (action,) + args, kw) + return action([], [], self) + def File(self, name, *args, **kw): """ """ diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index d450075..ca0b458 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1757,6 +1757,21 @@ class EnvironmentTestCase(unittest.TestCase): assert e2['X'] == 'xxx', e2['X'] assert e2['Y'] == 'yyy', e2['Y'] + def test_Execute(self): + """Test the Execute() method""" + + class MyAction: + def __init__(self, *args, **kw): + self.args = args + def __call__(self, target, source, env): + return "%s executed" % self.args + + env = Environment() + env.Action = MyAction + + result = env.Execute("foo") + assert result == "foo executed", result + def test_File(self): """Test the File() method""" class MyFS: diff --git a/src/engine/SCons/Script/SConscript.py b/src/engine/SCons/Script/SConscript.py index 2fa1510..d6e40fd 100644 --- a/src/engine/SCons/Script/SConscript.py +++ b/src/engine/SCons/Script/SConscript.py @@ -569,6 +569,8 @@ def get_DefaultEnvironmentProxy(): def subst_kw(self, kw, raw=0, target=None, source=None): return kw def subst_list(self, string, raw=0, target=None, source=None): + if not SCons.Util.is_List(string): + string = [[string]] return string default_env = SCons.Defaults.DefaultEnvironment() _DefaultEnvironmentProxy = EnvironmentProxy(default_env) @@ -619,6 +621,7 @@ GlobalDefaultEnvironmentFunctions = [ 'Command', 'Depends', 'Dir', + 'Execute', 'File', 'FindFile', 'GetBuildPath', |