From: stevenknight Date: Wed, 1 Jan 2003 18:02:19 +0000 (+0000) Subject: Don't duplicate source files in a BuildDir when the -n option is used. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ef79b758ea2e065601e63248d36b661d388d8a05;p=scons.git Don't duplicate source files in a BuildDir when the -n option is used. git-svn-id: http://scons.tigris.org/svn/scons/trunk@533 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index a02dc5c3..b9c63242 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 dee50dff..0569deae 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 ee21ae73..274c49bf 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()