targets = SCons.Node.arg2nodes(target, self.fs.File)
for side_effect in side_effects:
- if side_effect.builder is not None:
+ # A builder of 1 means the node is supposed to appear
+ # buildable without actually having a builder, so we allow
+ # it to be a side effect as well.
+ if side_effect.builder is not None and side_effect.builder != 1:
raise UserError, "Multiple ways to build the same target were specified for: %s" % str(side_effect)
side_effect.add_source(targets)
side_effect.side_effect = 1
else:
return self.entries['..'].root()
- def all_children(self, scanner):
+ def all_children(self, scan):
#XXX --random: randomize "dependencies?"
keys = filter(lambda k: k != '.' and k != '..', self.entries.keys())
kids = map(lambda x, s=self: s.entries[x], keys)
return 1
return 0
kids.sort(c)
- return kids
+ return kids + SCons.Node.Node.all_children(self, 0)
def build(self):
"""A null "builder" for directories."""
"""
assert test.read('log.txt') == expect
+test.write('SConstruct',
+"""
+import os.path
+import os
+
+def copy(source, target):
+ print 'copy() < %s > %s' % (source, target)
+ open(target, "wb").write(open(source, "rb").read())
+
+def build(env, source, target):
+ copy(str(source[0]), str(target[0]))
+ if target[0].side_effects:
+ try: os.mkdir('log')
+ except: pass
+ copy(str(target[0]), os.path.join('log', str(target[0])))
+
+Build = Builder(action=build)
+env = Environment(BUILDERS={'Build':Build})
+env.Build('foo.out', 'foo.in')
+env.Build('bar.out', 'bar.in')
+env.Build('blat.out', 'blat.in')
+env.SideEffect(Dir('log'), ['foo.out', 'bar.out', 'blat.out'])
+""")
+
+test.run(arguments='foo.out')
+
+test.fail_test(not os.path.exists(test.workpath('foo.out')))
+test.fail_test(not os.path.exists(test.workpath('log/foo.out')))
+test.fail_test(os.path.exists(test.workpath('log/bar.out')))
+test.fail_test(os.path.exists(test.workpath('log/blat.out')))
+
+test.run(arguments='log')
+test.fail_test(not os.path.exists(test.workpath('log/bar.out')))
+test.fail_test(not os.path.exists(test.workpath('log/blat.out')))
test.pass_test()