diff options
author | Steven Knight <knight@baldmt.com> | 2004-11-11 02:16:47 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-11-11 02:16:47 (GMT) |
commit | 8136dc27333b13b7b51d0e94819767adf10ac123 (patch) | |
tree | e5cd0b95dcb49860c9630226c2258c4b0957eea3 /src | |
parent | 0277e19ef2c747b4bb00233c172d407aeeb1eab8 (diff) | |
download | SCons-8136dc27333b13b7b51d0e94819767adf10ac123.zip SCons-8136dc27333b13b7b51d0e94819767adf10ac123.tar.gz SCons-8136dc27333b13b7b51d0e94819767adf10ac123.tar.bz2 |
Fix the use of reflective paths underneath build directories, when the path under the build_dir matches the path to the build_dir. (Kevin Quick)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 67 |
3 files changed, 86 insertions, 1 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 5f6968b..ded0c5c 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -264,6 +264,10 @@ RELEASE 0.97 - XXX - Python Function actions now have their calling signature (target, source, env) reported correctly when displayed. + - Fix BuildDir()/build_dir handling when the build_dir is underneath + the source directory and trying to use entries from the build_dir + as sources for other targets in the build-dir. + From Levi Stephen: - Allow $JARCHDIR to be expanded to other construction variables. diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 49cbe7d..5ee4abf 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -541,6 +541,11 @@ class Base(SCons.Node.Node): if dir.srcdir: self._srcnode = self.fs.Entry(name, dir.srcdir, klass=self.__class__) + if self._srcnode.is_under(dir): + # Shouldn't source from something in the build + # path: probably means build_dir is under + # src_dir and we are reflecting. + break return self._srcnode name = dir.name + os.sep + name dir=dir.get_dir() @@ -1101,8 +1106,17 @@ class FS(LocalFS): """ targets = [] message = None + start_dir = dir + start_tail = tail[:] while dir: for bd in dir.build_dirs: + if start_dir.is_under(bd): + # If already in the build-dir location, don't reflect + e = start_dir + if start_tail: + e = e.Entry(start_tail[0]) + targets.append(e) + continue p = apply(os.path.join, [bd.path] + tail) targets.append(self.Entry(p)) tail = [dir.name] + tail @@ -1669,7 +1683,7 @@ class File(Base): # Duplicate from source path if we are set up to do this. if self.duplicate and not self.is_derived() and not self.linked: src=self.srcnode().rfile() - if src.exists() and src.abspath != self.abspath: + if src.abspath != self.abspath and src.exists(): self._createDir() try: Unlink(self, None, None) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index c47435f..4031d3f 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -521,6 +521,73 @@ class BuildDirTestCase(unittest.TestCase): delattr(os, 'symlink') shutil.copy2 = real_copy + # Test BuildDir "reflection," where a same-named subdirectory + # exists underneath a build_dir. + fs = SCons.Node.FS.FS() + fs.BuildDir('work/src/b1/b2', 'work/src') + + dir_list = [ + 'work/src', + 'work/src/b1', + 'work/src/b1/b2', + 'work/src/b1/b2/b1', + 'work/src/b1/b2/b1/b2', + ] + + srcnode_map = { + 'work/src/b1/b2' : 'work/src', + 'work/src/b1/b2/f' : 'work/src/f', + 'work/src/b1/b2/b1' : 'work/src/b1/', + 'work/src/b1/b2/b1/f' : 'work/src/b1/f', + } + + alter_map = { + 'work/src' : 'work/src/b1/b2', + 'work/src/f' : 'work/src/b1/b2/f', + 'work/src/b1' : 'work/src/b1/b2/b1', + 'work/src/b1/f' : 'work/src/b1/b2/b1/f', + } + + errors = 0 + + for dir in dir_list: + dnode = fs.Dir(dir) + f = dir + '/f' + fnode = fs.File(dir + '/f') + + dp = dnode.srcnode().path + expect = os.path.normpath(srcnode_map.get(dir, dir)) + if dp != expect: + print "Dir `%s' srcnode() `%s' != expected `%s'" % (dir, dp, expect) + errors = errors + 1 + + fp = fnode.srcnode().path + expect = os.path.normpath(srcnode_map.get(f, f)) + if fp != expect: + print "File `%s' srcnode() `%s' != expected `%s'" % (f, fp, expect) + errors = errors + 1 + + for dir in dir_list: + dnode = fs.Dir(dir) + f = dir + '/f' + fnode = fs.File(dir + '/f') + + t, m = dnode.alter_targets() + tp = t[0].path + expect = os.path.normpath(alter_map.get(dir, dir)) + if tp != expect: + print "Dir `%s' alter_targets() `%s' != expected `%s'" % (dir, tp, expect) + errors = errors + 1 + + t, m = fnode.alter_targets() + tp = t[0].path + expect = os.path.normpath(alter_map.get(f, f)) + if tp != expect: + print "File `%s' alter_targets() `%s' != expected `%s'" % (f, tp, expect) + errors = errors + 1 + + self.failIf(errors) + class FSTestCase(unittest.TestCase): def runTest(self): """Test FS (file system) Node operations |