diff options
author | Steven Knight <knight@baldmt.com> | 2004-10-21 12:07:26 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-10-21 12:07:26 (GMT) |
commit | c9c69b3bd0dd817e589efcc83643e45071d2a95c (patch) | |
tree | 803f5bc5122b2a22d15f8375bab9361164487a6c | |
parent | 3e52ca38ff11bf7515dbeb05af362f370479bfb4 (diff) | |
download | SCons-c9c69b3bd0dd817e589efcc83643e45071d2a95c.zip SCons-c9c69b3bd0dd817e589efcc83643e45071d2a95c.tar.gz SCons-c9c69b3bd0dd817e589efcc83643e45071d2a95c.tar.bz2 |
Handle use of Mkdir() when the file exists.
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 9 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 7 | ||||
-rw-r--r-- | test/Mkdir.py | 12 |
4 files changed, 28 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 5a4062f..df34c85 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -100,6 +100,10 @@ RELEASE 0.97 - XXX - Fix the ability to specify a target_factory of Dir() to a Builder, which the default create-a-directory Builder was interfering with. + - Mark a directory as built if it's created as part of the preparation + for another target, to avoid trying to build it again when it comes + up in the target list. + From Clive Levinson: - Make ParseConfig() recognize and add -mno-cygwin to $LINKFLAGS and diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 883b82c..1e24be0 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -1507,7 +1507,7 @@ class File(Base): return includes - def _createDir(self): + def _createDir(self, update=None): # ensure that the directories for this node are # created. @@ -1529,6 +1529,11 @@ class File(Base): # directory. The dirnode.build() method will suppress # the build if it's the default builder. SCons.Node.Node.build(dirnode) + if update: + # Mark this directory as built so we don't try to build + # it again if it has an explicit user-defined Builder. + dirnode.set_state(SCons.Node.executed) + dirnode.built() # The build() action may or may not have actually # created the directory, depending on whether the -n # option was used or not. Delete the _exists and @@ -1667,7 +1672,7 @@ class File(Base): pass else: try: - self._createDir() + self._createDir(update=1) except SCons.Errors.StopError, drive: desc = "No drive `%s' for target `%s'." % (drive, self) raise SCons.Errors.StopError, desc diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 2259b7b..67c4ffe 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1504,7 +1504,7 @@ class prepareTestCase(unittest.TestCase): """Test the prepare() method""" class MyFile(SCons.Node.FS.File): - def _createDir(self): + def _createDir(self, update=None): raise SCons.Errors.StopError def exists(self): return None @@ -1533,9 +1533,14 @@ class prepareTestCase(unittest.TestCase): xyz.set_state(SCons.Node.up_to_date) xyz.prepare() assert dir_made == [], dir_made + state = new_dir.get_state() + assert state != SCons.Node.executed, state + xyz.set_state(0) xyz.prepare() assert dir_made[0].path == "new_dir", dir_made[0] + state = new_dir.get_state() + assert state == SCons.Node.executed, state dir = fs.Dir("dir") dir.prepare() diff --git a/test/Mkdir.py b/test/Mkdir.py index cdbcd4b..a198571 100644 --- a/test/Mkdir.py +++ b/test/Mkdir.py @@ -51,6 +51,11 @@ env.Command('f5.out', 'f5.in', [Mkdir("$DIR"), Cat]) env.Command('f6.out', 'f6.in', [Cat, Mkdir("Mkdir-$SOURCE"), Mkdir("$TARGET-Mkdir")]) +# Make sure that a user-defined Mkdir builder on a directory +# doesn't get executed twice if it has to get called to create +# directory for another target. +env.Command(Dir('hello'), None, [Mkdir('$TARGET')]) +env.Command('hello/world', None, [Touch('$TARGET')]) """) test.write('f2.in', "f2.in\n") @@ -66,7 +71,9 @@ cat(["f5.out"], ["f5.in"]) cat(["f6.out"], ["f6.in"]) Mkdir("Mkdir-f6.in") Mkdir("f6.out-Mkdir") -""") +Mkdir("hello") +Touch("%s") +""" % (os.path.join('hello', 'world'))) test.run(options = '-n', arguments = '.', stdout = expect) test.must_not_exist('d1') @@ -88,10 +95,13 @@ test.must_match('f5.out', "f5.in\n") test.must_exist('f6.out') test.must_exist('Mkdir-f6.in') test.must_exist('f6.out-Mkdir') +test.must_exist('hello') +test.must_exist('hello/world') test.write(['d1', 'file'], "d1/file\n") test.write(['d3', 'file'], "d3/file\n") test.write(['Mkdir-f6.in', 'file'], "Mkdir-f6.in/file\n") test.write(['f6.out-Mkdir', 'file'], "f6.out-Mkdir/file\n") +test.write(['hello', 'file'], "hello/file\n") test.pass_test() |