Fix a scanner bug for repository files included by relative path. (Charles Crain)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 5 Nov 2002 14:46:15 +0000 (14:46 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 5 Nov 2002 14:46:15 +0000 (14:46 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@491 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Scanner/C.py
src/engine/SCons/Scanner/CTests.py
src/engine/SCons/Scanner/Fortran.py
src/engine/SCons/Scanner/FortranTests.py

index 47b6ea7085a9d00e413121b78ce11733c64df229..0e6e5d38353342fb0cd119141e61833358f4d1f5 100644 (file)
@@ -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:
index 6b949e8bc1ba818ff12121c3fd42575d2ed89d4e..b91200f2451795f18712b4ce97e7d9e3c0006e71 100644 (file)
@@ -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__":
index fd8c971675601a372487a3c9d6917b70eddadcb6..5c4f69dd59698f3f4c81d34781caadb66f466d84 100644 (file)
@@ -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:
index e882153bd1ecd5c570356fc7032b930f5119b0c5..9806d60f68a83965805d08016428a46b3fbad085 100644 (file)
@@ -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__":