summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-03-12 13:24:18 (GMT)
committerSteven Knight <knight@baldmt.com>2004-03-12 13:24:18 (GMT)
commit7f0857e23182eb4fba10dc65216c65dbe7ee13da (patch)
treece7ad48e3d0e7cd9708904c8ceedad4da4125090 /src
parent503c526b323d74874ee99ae5d54b30f45046ce00 (diff)
downloadSCons-7f0857e23182eb4fba10dc65216c65dbe7ee13da.zip
SCons-7f0857e23182eb4fba10dc65216c65dbe7ee13da.tar.gz
SCons-7f0857e23182eb4fba10dc65216c65dbe7ee13da.tar.bz2
Add an Execute() method.
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/engine/SCons/Environment.py6
-rw-r--r--src/engine/SCons/EnvironmentTests.py15
-rw-r--r--src/engine/SCons/Script/SConscript.py3
4 files changed, 26 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index a8f0ecc..285ffbe 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -12,6 +12,8 @@ RELEASE 0.96 - XXX
From Steven Knight:
+ - Add an Execute() method for executing actions directly.
+
RELEASE 0.95 - Mon, 08 Mar 2004 06:43:20 -0600
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',