diff options
author | Steven Knight <knight@baldmt.com> | 2002-11-25 17:22:28 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-11-25 17:22:28 (GMT) |
commit | 22c249b07f1831b86aca87ba1728a0cf19884b80 (patch) | |
tree | da3663b86e140824200771d866cfa6a01ee724d3 | |
parent | eaef3f7c8cd75bd92b75233bfbee8589f2b9e82b (diff) | |
download | SCons-22c249b07f1831b86aca87ba1728a0cf19884b80.zip SCons-22c249b07f1831b86aca87ba1728a0cf19884b80.tar.gz SCons-22c249b07f1831b86aca87ba1728a0cf19884b80.tar.bz2 |
Make env.SideEffect work for Dir nodes. (Anthony Roach)
-rw-r--r-- | src/engine/SCons/Environment.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 4 | ||||
-rw-r--r-- | test/SideEffect.py | 34 |
3 files changed, 40 insertions, 3 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index c0b3255..ec8f1eb 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -374,7 +374,10 @@ class Environment: 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 diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index d66b777..59b8e63 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -644,7 +644,7 @@ class Dir(Entry): 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) @@ -655,7 +655,7 @@ class Dir(Entry): 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.""" diff --git a/test/SideEffect.py b/test/SideEffect.py index 6337f68..3f3b75d 100644 --- a/test/SideEffect.py +++ b/test/SideEffect.py @@ -118,5 +118,39 @@ foo.in -> foo.out """ 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() |