diff options
author | Steven Knight <knight@baldmt.com> | 2003-01-01 18:02:19 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-01-01 18:02:19 (GMT) |
commit | d88f61db921461663b934595e38a15e2ca09c225 (patch) | |
tree | ea3f81da45529588e0d4a0a598a3e568ae20feaf | |
parent | 2875346f645fe24a249122069b1568fcff032643 (diff) | |
download | SCons-d88f61db921461663b934595e38a15e2ca09c225.zip SCons-d88f61db921461663b934595e38a15e2ca09c225.tar.gz SCons-d88f61db921461663b934595e38a15e2ca09c225.tar.bz2 |
Don't duplicate source files in a BuildDir when the -n option is used.
-rw-r--r-- | src/CHANGES.txt | 3 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 30 | ||||
-rw-r--r-- | test/option-n.py | 10 |
3 files changed, 27 insertions, 16 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a02dc5c..b9c6324 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -25,6 +25,9 @@ RELEASE 0.10 - XXX - Fix the Install() method so that, like other actions, it prints what would have happened when the -n option is used. + - Don't create duplicate source files in a BuildDir when the -n + option is used. + From Steve Leblanc: - Add a Clean() method to support removing user-specified targets diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index dee50df..0569dea 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -789,7 +789,7 @@ class File(Entry): def _morph(self): """Turn a file system node into a File object.""" - self.created = 0 + self.linked = 0 if not hasattr(self, '_local'): self._local = 0 @@ -880,9 +880,16 @@ class File(Entry): parent = p listDirs.reverse() for dirnode in listDirs: - dirnode._exists = 1 try: Mkdir(dirnode, None, None) + # The Mkdir() action may or may not have actually + # created the directory, depending on whether the -n + # option was used or not. Delete the _exists and + # _rexists attributes so they can be reevaluated. + if hasattr(dirnode, '_exists'): + delattr(dirnode, '_exists') + if hasattr(dirnode, '_rexists'): + delattr(dirnode, '_rexists') except OSError: pass @@ -897,7 +904,7 @@ class File(Entry): """Prepare for this file to be created.""" def missing(node): - return not node.builder and not node.rexists() + return not node.builder and not node.linked and not node.rexists() missing_sources = filter(missing, self.children()) if missing_sources: desc = "No Builder for target `%s', needed by `%s'." % (missing_sources[0], self) @@ -924,7 +931,7 @@ class File(Entry): def exists(self): # Duplicate from source path if we are set up to do this. - if self.duplicate and not self.builder and not self.created: + if self.duplicate and not self.builder and not self.linked: src=self.srcnode().rfile() if src.exists() and src.abspath != self.abspath: self._createDir() @@ -933,12 +940,15 @@ class File(Entry): except OSError: pass Link(self, src, None) - self.created = 1 - - # Set our exists cache accordingly - self._exists=1 - self._rexists=1 - return 1 + self.linked = 1 + # The Link() action may or may not have actually + # created the file, depending on whether the -n + # option was used or not. Delete the _exists and + # _rexists attributes so they can be reevaluated. + if hasattr(self, '_exists'): + delattr(self, '_exists') + if hasattr(self, '_rexists'): + delattr(self, '_rexists') return Entry.exists(self) def current(self, calc): diff --git a/test/option-n.py b/test/option-n.py index ee21ae7..274c49b 100644 --- a/test/option-n.py +++ b/test/option-n.py @@ -135,12 +135,10 @@ test.write('f3.in', "f3.in again\n") test.run(arguments = '-n install', stdout = expect) test.fail_test(not os.path.exists(test.workpath('install', 'f3.in'))) -# This last test (duplicate BuildDir files not getting created when -# -n is used) still fails, but it's going to take more time to -# work out the details of the fix. And since it's not a bug that -# destroys anything, we're going to leave it alone for now. -#test.run(arguments = '-n build') -#test.fail_test(os.path.exists(test.workpath('build', 'f4.in'))) +# Make sure duplicate source files in a BuildDir aren't created +# when the -n option is used. +test.run(arguments = '-n build') +test.fail_test(os.path.exists(test.workpath('build', 'f4.in'))) test.pass_test() |