From: stevenknight Date: Tue, 5 Nov 2002 14:46:15 +0000 (+0000) Subject: Fix a scanner bug for repository files included by relative path. (Charles Crain) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5ed410aba21e0e9d732f671a36c369272f090087;p=scons.git Fix a scanner bug for repository files included by relative path. (Charles Crain) git-svn-id: http://scons.tigris.org/svn/scons/trunk@491 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index 47b6ea70..0e6e5d38 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -86,8 +86,9 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs): cpppath = target.cpppath + node = node.rfile() if not node.found_includes.has_key(cpppath): - if node.rexists(): + if node.exists(): # cache the includes list in node so we only scan it once: if node.includes != None: diff --git a/src/engine/SCons/Scanner/CTests.py b/src/engine/SCons/Scanner/CTests.py index 6b949e8b..b91200f2 100644 --- a/src/engine/SCons/Scanner/CTests.py +++ b/src/engine/SCons/Scanner/CTests.py @@ -119,7 +119,8 @@ test.write(['subdir', 'include', 'fa.h'], "\n") test.write(['subdir', 'include', 'fb.h'], "\n") -test.subdir('repository', ['repository', 'include']) +test.subdir('repository', ['repository', 'include'], + ['repository', 'src' ]) test.subdir('work', ['work', 'src']) test.write(['repository', 'include', 'iii.h'], "\n") @@ -133,6 +134,28 @@ int main() } """) +test.write([ 'work', 'src', 'aaa.c'], """ +#include "bbb.h" + +int main() +{ + return 0; +} +""") + +test.write([ 'work', 'src', 'bbb.h'], "\n") + +test.write([ 'repository', 'src', 'ccc.c'], """ +#include "ddd.h" + +int main() +{ + return 0; +} +""") + +test.write([ 'repository', 'src', 'ddd.h'], "\n") + # define some helpers: class DummyTarget: @@ -160,6 +183,7 @@ class DummyEnvironment: def __delitem__(self,key): del self.Dictionary()[key] +global my_normpath my_normpath = os.path.normpath if os.path.normcase('foo') == os.path.normcase('FOO'): global my_normpath @@ -301,6 +325,26 @@ class CScannerTestCase11(unittest.TestCase): deps_match(self, deps, [test.workpath('repository/include/iii.h')]) os.chdir(test.workpath('')) +class CScannerTestCase12(unittest.TestCase): + def runTest(self): + os.chdir(test.workpath('work')) + fs = SCons.Node.FS.FS(test.workpath('work')) + fs.BuildDir('build1', 'src', 1) + fs.BuildDir('build2', 'src', 0) + fs.Repository(test.workpath('repository')) + env = DummyEnvironment([]) + s = SCons.Scanner.C.CScan(fs = fs) + deps1 = s.scan(fs.File('build1/aaa.c'), env, DummyTarget()) + deps_match(self, deps1, [ 'build1/bbb.h' ]) + deps2 = s.scan(fs.File('build2/aaa.c'), env, DummyTarget()) + deps_match(self, deps2, [ 'src/bbb.h' ]) + deps3 = s.scan(fs.File('build1/ccc.c'), env, DummyTarget()) + deps_match(self, deps3, [ 'build1/ddd.h' ]) + deps4 = s.scan(fs.File('build2/ccc.c'), env, DummyTarget()) + deps_match(self, deps4, [ test.workpath('repository/src/ddd.h') ]) + os.chdir(test.workpath('')) + + def suite(): suite = unittest.TestSuite() suite.addTest(CScannerTestCase1()) @@ -313,6 +357,7 @@ def suite(): suite.addTest(CScannerTestCase9()) suite.addTest(CScannerTestCase10()) suite.addTest(CScannerTestCase11()) + suite.addTest(CScannerTestCase12()) return suite if __name__ == "__main__": diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py index fd8c9716..5c4f69dd 100644 --- a/src/engine/SCons/Scanner/Fortran.py +++ b/src/engine/SCons/Scanner/Fortran.py @@ -86,6 +86,7 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs): nodes = [] + node = node.rfile() try: nodes = node.found_includes[f77path] except KeyError: diff --git a/src/engine/SCons/Scanner/FortranTests.py b/src/engine/SCons/Scanner/FortranTests.py index e882153b..9806d60f 100644 --- a/src/engine/SCons/Scanner/FortranTests.py +++ b/src/engine/SCons/Scanner/FortranTests.py @@ -93,7 +93,8 @@ test.write('include/f4.f', "\n") test.write('subdir/include/f4.f', "\n") -test.subdir('repository', ['repository', 'include']) +test.subdir('repository', ['repository', 'include'], + [ 'repository', 'src' ]) test.subdir('work', ['work', 'src']) test.write(['repository', 'include', 'iii.f'], "\n") @@ -105,6 +106,24 @@ test.write(['work', 'src', 'fff.f'], """ END """) +test.write([ 'work', 'src', 'aaa.f'], """ + PROGRAM FOO + INCLUDE 'bbb.f' + STOP + END +""") + +test.write([ 'work', 'src', 'bbb.f'], "\n") + +test.write([ 'repository', 'src', 'ccc.f'], """ + PROGRAM FOO + INCLUDE 'ddd.f' + STOP + END +""") + +test.write([ 'repository', 'src', 'ddd.f'], "\n") + # define some helpers: class DummyTarget: @@ -310,6 +329,25 @@ class FortranScannerTestCase13(unittest.TestCase): deps_match(self, deps, [test.workpath('repository/include/iii.f')]) os.chdir(test.workpath('')) +class FortranScannerTestCase14(unittest.TestCase): + def runTest(self): + os.chdir(test.workpath('work')) + fs = SCons.Node.FS.FS(test.workpath('work')) + fs.BuildDir('build1', 'src', 1) + fs.BuildDir('build2', 'src', 0) + fs.Repository(test.workpath('repository')) + env = DummyEnvironment([]) + s = SCons.Scanner.Fortran.FortranScan(fs = fs) + deps1 = s.scan(fs.File('build1/aaa.f'), env, DummyTarget()) + deps_match(self, deps1, [ 'build1/bbb.f' ]) + deps2 = s.scan(fs.File('build2/aaa.f'), env, DummyTarget()) + deps_match(self, deps2, [ 'src/bbb.f' ]) + deps3 = s.scan(fs.File('build1/ccc.f'), env, DummyTarget()) + deps_match(self, deps3, [ 'build1/ddd.f' ]) + deps4 = s.scan(fs.File('build2/ccc.f'), env, DummyTarget()) + deps_match(self, deps4, [ test.workpath('repository/src/ddd.f') ]) + os.chdir(test.workpath('')) + def suite(): suite = unittest.TestSuite() suite.addTest(FortranScannerTestCase1()) @@ -325,6 +363,7 @@ def suite(): suite.addTest(FortranScannerTestCase11()) suite.addTest(FortranScannerTestCase12()) suite.addTest(FortranScannerTestCase13()) + suite.addTest(FortranScannerTestCase14()) return suite if __name__ == "__main__":