From: stevenknight Date: Tue, 14 May 2002 21:08:38 +0000 (+0000) Subject: Fix for relative CPPPATH when BuildDir() is in use. (Charles Crain) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8fa9deffb13c6c69526a85f5bfc301e422162f0f;p=scons.git Fix for relative CPPPATH when BuildDir() is in use. (Charles Crain) git-svn-id: http://scons.tigris.org/svn/scons/trunk@372 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ee716a59..ebcd7f54 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,11 @@ RELEASE 0.08 - + From Charles Crain: + + - Fixed a bug with relative CPPPATH dirs when using BuildDir(). + (Bug reported by Bob Summerwill.) + From Steven Knight: - Add a "platform=" keyword argument to Environment instantiation, diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 6ccd1460..61cd80c6 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -499,6 +499,21 @@ class Dir(Entry): self._sconsign = SCons.Sig.SConsignFile(self) return self._sconsign + def __str__(self): + # Reimplemented from Entry since, unlike for + # Entry and File, we want to return the source + # path *even if* the builder is non-zero + # (which it always is for a directory) + if self.duplicate: + return self.path + else: + return self.srcpath + + def exists(self): + # Again, directories are special...we don't care if their + # source path exists, we only care about the path. + return os.path.exists(self.path) + # XXX TODO? diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index ef0c72bb..ee825637 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -108,6 +108,12 @@ class BuildDirTestCase(unittest.TestCase): assert f2.srcpath == os.path.normpath('src/test1'), str(f2) assert str(f2) == os.path.normpath('build/var2/test1'), str(f2) + d1 = fs.Dir('build/var1') + d2 = fs.Dir('build/var2') + + assert str(d1) == 'src', str(d1) + assert str(d2) == os.path.normpath('build/var2'), str(d2) + # Test to see if file_link() works... test=TestCmd(workdir='') test.subdir('src','build') diff --git a/test/BuildDir.py b/test/BuildDir.py index 4b835a6b..c547ef90 100644 --- a/test/BuildDir.py +++ b/test/BuildDir.py @@ -44,18 +44,22 @@ foo31 = test.workpath('build', 'var3', 'foo1' + _exe) foo32 = test.workpath('build', 'var3', 'foo2' + _exe) foo41 = test.workpath('build', 'var4', 'foo1' + _exe) foo42 = test.workpath('build', 'var4', 'foo2' + _exe) +foo51 = test.workpath('build', 'var5', 'foo1' + _exe) +foo52 = test.workpath('build', 'var5', 'foo2' + _exe) test.write('SConstruct', """ src = Dir('src') var2 = Dir('build/var2') var3 = Dir('build/var3') var4 = Dir('build/var4') +var5 = Dir('build/var5') BuildDir('build/var1', src) BuildDir(var2, src) BuildDir(var3, src, duplicate=0) BuildDir(var4, src, duplicate=0) +BuildDir(var5, src, duplicate=0) env = Environment(CPPPATH='#src') SConscript('build/var1/SConscript', "env") @@ -65,6 +69,8 @@ env = Environment(CPPPATH=src) SConscript('build/var3/SConscript', "env") SConscript(File('SConscript', var4), "env") +env = Environment(CPPPATH='.') +SConscript('build/var5/SConscript', "env") """) test.subdir('src') @@ -129,14 +135,20 @@ test.run(program = foo31, stdout = "f1.c\n") test.run(program = foo32, stdout = "f2.c\n") test.run(program = foo41, stdout = "f1.c\n") test.run(program = foo42, stdout = "f2.c\n") +test.run(program = foo51, stdout = "f1.c\n") +test.run(program = foo52, stdout = "f2.c\n") # Make sure we didn't duplicate the source files in build/var3. test.fail_test(os.path.exists(test.workpath('build', 'var3', 'f1.c'))) test.fail_test(os.path.exists(test.workpath('build', 'var3', 'f2.in'))) -# Make sure we didn't duplicate the source files in build/var3. +# Make sure we didn't duplicate the source files in build/var4. test.fail_test(os.path.exists(test.workpath('build', 'var4', 'f1.c'))) test.fail_test(os.path.exists(test.workpath('build', 'var4', 'f2.in'))) +# Make sure we didn't duplicate the source files in build/var5. +test.fail_test(os.path.exists(test.workpath('build', 'var5', 'f1.c'))) +test.fail_test(os.path.exists(test.workpath('build', 'var5', 'f2.in'))) + test.pass_test()