summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-11-05 14:46:15 (GMT)
committerSteven Knight <knight@baldmt.com>2002-11-05 14:46:15 (GMT)
commitd3a159a23fdeaa76c7931c7f8b1b7dafd43b4b99 (patch)
tree5380dd6be92bc1668aaaac5269da2be11dc9edec
parent69706b07d4bb5b71abbae236432bba2bbaf916d1 (diff)
downloadSCons-d3a159a23fdeaa76c7931c7f8b1b7dafd43b4b99.zip
SCons-d3a159a23fdeaa76c7931c7f8b1b7dafd43b4b99.tar.gz
SCons-d3a159a23fdeaa76c7931c7f8b1b7dafd43b4b99.tar.bz2
Fix a scanner bug for repository files included by relative path. (Charles Crain)
-rw-r--r--src/engine/SCons/Scanner/C.py3
-rw-r--r--src/engine/SCons/Scanner/CTests.py47
-rw-r--r--src/engine/SCons/Scanner/Fortran.py1
-rw-r--r--src/engine/SCons/Scanner/FortranTests.py41
4 files changed, 89 insertions, 3 deletions
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py
index 47b6ea7..0e6e5d3 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 6b949e8..b91200f 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 fd8c971..5c4f69d 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 e882153..9806d60 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__":