summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2001-12-07 00:29:20 (GMT)
committerSteven Knight <knight@baldmt.com>2001-12-07 00:29:20 (GMT)
commit9ca1ac7a1f54fafa93713e3ff6bff693ca180d3e (patch)
tree7644c76e7330ecea3b6c1a8dfe7bc5b68b1ddd62 /src
parenta12957948f90147743ecf2368a9a348c8619a09b (diff)
downloadSCons-9ca1ac7a1f54fafa93713e3ff6bff693ca180d3e.zip
SCons-9ca1ac7a1f54fafa93713e3ff6bff693ca180d3e.tar.gz
SCons-9ca1ac7a1f54fafa93713e3ff6bff693ca180d3e.tar.bz2
Fix problems with Python callable objects as Builder actions, the associated test, and handling errors returned by a builder.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Builder.py6
-rw-r--r--src/engine/SCons/BuilderTests.py4
-rw-r--r--src/engine/SCons/EnvironmentTests.py14
-rw-r--r--src/engine/SCons/Script.py2
4 files changed, 16 insertions, 10 deletions
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py
index 2d2d623..983e32f 100644
--- a/src/engine/SCons/Builder.py
+++ b/src/engine/SCons/Builder.py
@@ -350,7 +350,8 @@ class ActionBase:
if type(t) is type(""):
t = [t]
dict['TARGETS'] = PathList(map(os.path.normpath, t))
- dict['TARGET'] = dict['TARGETS'][0]
+ if dict['TARGETS']:
+ dict['TARGET'] = dict['TARGETS'][0]
if kw.has_key('source'):
s = kw['source']
del kw['source']
@@ -407,8 +408,7 @@ class FunctionAction(ActionBase):
# if print_actions:
# XXX: WHAT SHOULD WE PRINT HERE?
if execute_actions:
- dict = apply(self.subst_dict, (), kw)
- return apply(self.function, (), dict)
+ return apply(self.function, (), kw)
def get_contents(self, **kw):
"""Return the signature contents of this callable action.
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py
index 54776ff..4c6ad1f 100644
--- a/src/engine/SCons/BuilderTests.py
+++ b/src/engine/SCons/BuilderTests.py
@@ -190,11 +190,11 @@ class BuilderTestCase(unittest.TestCase):
assert show_string == expect7, show_string
def function1(**kw):
- open(kw['out'], 'w').write("function1\n")
+ open(kw['target'], 'w').write("function1\n")
return 1
builder = SCons.Builder.Builder(action = function1)
- r = builder.execute(out = outfile)
+ r = builder.execute(target = outfile)
assert r == 1
c = test.read(outfile, 'r')
assert c == "function1\n", c
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 3341c83..82b19be 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -234,11 +234,17 @@ class EnvironmentTestCase(unittest.TestCase):
assert 'foo1.in' in map(lambda x: x.path, t.sources)
assert 'foo2.in' in map(lambda x: x.path, t.sources)
- def testFunc(ENV, target, source):
+ def testFunc(env, target, source):
assert target == 'foo.out'
- assert source == 'foo1.in foo2.in' or source == 'foo2.in foo1.in'
- env.Command(target='foo.out', source=['foo1.in','foo2.in'],
- action=testFunc)
+ assert 'foo1.in' in source and 'foo2.in' in source, source
+ return 0
+ t = env.Command(target='foo.out', source=['foo1.in','foo2.in'],
+ action=testFunc)
+ assert t.builder
+ assert t.builder.action.__class__.__name__ == 'FunctionAction'
+ t.build()
+ assert 'foo1.in' in map(lambda x: x.path, t.sources)
+ assert 'foo2.in' in map(lambda x: x.path, t.sources)
def test_subst(self):
"""Test substituting construction variables within strings
diff --git a/src/engine/SCons/Script.py b/src/engine/SCons/Script.py
index 3857df6..836fb1a 100644
--- a/src/engine/SCons/Script.py
+++ b/src/engine/SCons/Script.py
@@ -80,7 +80,7 @@ class BuildTask(SCons.Taskmaster.Task):
try:
self.target.build()
except BuildError, e:
- sys.stderr.write("scons: *** [%s] Error %d\n" % (e.node, e.stat))
+ sys.stderr.write("scons: *** [%s] Error %s\n" % (e.node, str(e.stat)))
raise
def failed(self):