diff options
author | Steven Knight <knight@baldmt.com> | 2001-12-11 01:53:48 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-12-11 01:53:48 (GMT) |
commit | ee1ca39a5afec8c92e9d427dd18cbd655a2e46dc (patch) | |
tree | 42fd27b36d6607aa6b31fde639b53bd15852bacb /src | |
parent | 9ca1ac7a1f54fafa93713e3ff6bff693ca180d3e (diff) | |
download | SCons-ee1ca39a5afec8c92e9d427dd18cbd655a2e46dc.zip SCons-ee1ca39a5afec8c92e9d427dd18cbd655a2e46dc.tar.gz SCons-ee1ca39a5afec8c92e9d427dd18cbd655a2e46dc.tar.bz2 |
Refactor the Builder execute() interface to take Nodes, not string names of targets and sources.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Builder.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/BuilderTests.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 3 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 3 |
4 files changed, 29 insertions, 7 deletions
diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 983e32f..1525804 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -347,17 +347,17 @@ class ActionBase: if kw.has_key('target'): t = kw['target'] del kw['target'] - if type(t) is type(""): + if not type(t) is types.ListType: t = [t] - dict['TARGETS'] = PathList(map(os.path.normpath, t)) + dict['TARGETS'] = PathList(map(os.path.normpath, map(str, t))) if dict['TARGETS']: dict['TARGET'] = dict['TARGETS'][0] if kw.has_key('source'): s = kw['source'] del kw['source'] - if type(s) is type(""): + if not type(s) is types.ListType: s = [s] - dict['SOURCES'] = PathList(map(os.path.normpath, s)) + dict['SOURCES'] = PathList(map(os.path.normpath, map(str, s))) dict.update(kw) @@ -408,6 +408,13 @@ class FunctionAction(ActionBase): # if print_actions: # XXX: WHAT SHOULD WE PRINT HERE? if execute_actions: + if kw.has_key('target'): + if type(kw['target']) is types.ListType: + kw['target'] = map(str, kw['target']) + else: + kw['target'] = str(kw['target']) + if kw.has_key('source'): + kw['source'] = map(str, kw['source']) return apply(self.function, (), kw) def get_contents(self, **kw): diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 4c6ad1f..9143a5f 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -171,6 +171,21 @@ class BuilderTestCase(unittest.TestCase): c = test.read(outfile, 'r') assert c == "act.py: 'out5' 'XYZZY'\nact.py: 'xyzzy'\n", c + class Obj: + def __init__(self, str): + self._str = str + def __str__(self): + return self._str + + cmd6 = r'%s %s %s ${TARGETS[1]} $TARGET ${SOURCES[:2]}' % (python, act_py, outfile) + + builder = SCons.Builder.Builder(action = cmd6) + r = builder.execute(target = [Obj('111'), Obj('222')], + source = [Obj('333'), Obj('444'), Obj('555')]) + assert r == 0 + c = test.read(outfile, 'r') + assert c == "act.py: '222' '111' '333' '444'\n", c + cmd7 = '%s %s %s one\n\n%s %s %s two' % (python, act_py, outfile, python, act_py, outfile) expect7 = '%s %s %s one\n%s %s %s two\n' % (python, act_py, outfile, diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 2eba47e..a3590a1 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -90,7 +90,8 @@ class NodeTestCase(unittest.TestCase): node.sources = ["yyy", "zzz"] node.build() assert built_it - assert built_target == "xxx", built_target + assert type(built_target) == type(MyNode()), type(built_target) + assert str(built_target) == "xxx", str(built_target) assert built_source == ["yyy", "zzz"], built_source def test_builder_set(self): diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 83663dc..8b1ef55 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -71,9 +71,8 @@ class Node: """Actually build the node. Return the status from the build.""" if not self.builder: return None - sources = map(lambda x: str(x), self.sources) stat = self.builder.execute(env = self.env.Dictionary(), - target = str(self), source = sources) + target = self, source = self.sources) if stat != 0: raise BuildError(node = self, stat = stat) return stat |