Refactor the interface between Rsearch() and Rsearchall() and their supplied function...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 8 Aug 2002 18:22:55 +0000 (18:22 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 8 Aug 2002 18:22:55 +0000 (18:22 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@435 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Environment.py
src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Scanner/C.py
src/engine/SCons/Scanner/Fortran.py

index fea60c3fdca0bb1f1e8bc97825f2d6efbc1cd62b..4a86ae60c8eff2d7f12e1b1ad149ba0c11bf7403 100644 (file)
@@ -489,7 +489,9 @@ class DirVarInterp(VarInterpolator):
 
     def prepareSrc(self, dict):
         src = VarInterpolator.prepareSrc(self, dict)
-        def path_dirs(path, fs = self.fs, dir = self.dir):
+        def path_dirs(rep, path, fs=self.fs, dir=self.dir):
+            if rep:
+                path = os.path.join(rep, path)
             return fs.Dir(path, directory = dir)
         return self.fs.Rsearchall(src, path_dirs)
 
index d438cd040b6d6b446cf03b20d11197dffce9c28e..1c90ea8fa9bd6ae2d9ada0074469d53de77d018b 100644 (file)
@@ -84,9 +84,11 @@ else:
         return string.upper(x)
 
 
-def exists_path(path):
+def exists_path(rep, path):
     """Return a path if it's already a Node or it exists in the
     real filesystem."""
+    if rep:
+        path = os.path.join(rep, path)
     if os.path.exists(path):
         return path
     return None
@@ -317,11 +319,11 @@ class FS:
         if isinstance(path, SCons.Node.Node):
             return path
         else:
-            n = func(path)
+            n = func(None, path)
             if n:
                 return n
             for dir in self.Repositories:
-                n = func(os.path.join(dir.path, path))
+                n = func(dir.path, path)
                 if n:
                     return n
         return None
@@ -337,14 +339,14 @@ class FS:
             if isinstance(path, SCons.Node.Node):
                 ret.append(path)
             else:
-                n = func(path)
+                n = func(None, path)
                 if n:
                     ret.append(n)
                 if not os.path.isabs(path):
                     if path[0] == '#':
                         path = path[1:]
                     for dir in self.Repositories:
-                        n = func(os.path.join(dir.path, path))
+                        n = func(dir.path, path)
                         if n:
                             ret.append(n)
         return ret
@@ -778,7 +780,9 @@ class File(Entry):
         if not hasattr(self, '_rfile'):
             self._rfile = self
             if not os.path.isabs(self.path) and not os.path.isfile(self.path):
-                def file_node(path, fs = self.fs):
+                def file_node(dir, path, fs=self.fs):
+                    if dir:
+                        path = os.path.join(dir, path)
                     if os.path.isfile(path):
                         return fs.File(path)
                     return None
index b45cc4ba2afd8be855af37c44737cd2f0a1bb491..5945f3f8a1145bbe1aaadc272f926746142578d3 100644 (file)
@@ -597,9 +597,14 @@ class RepositoryTestCase(unittest.TestCase):
         assert fs.Rsearch('f2')
         assert fs.Rsearch(f3) is f3
 
-        assert not fs.Rsearch('f1', os.path.exists)
-        assert fs.Rsearch('f2', os.path.exists)
-        assert fs.Rsearch('f3', os.path.exists)
+        def my_exists(rep, path):
+            if rep:
+                path = os.path.join(rep, path)
+            return os.path.exists(path)
+
+        assert not fs.Rsearch('f1', my_exists)
+        assert fs.Rsearch('f2', my_exists)
+        assert fs.Rsearch('f3', my_exists)
 
         list = fs.Rsearchall(fs.Dir('d1'))
         assert len(list) == 1, list
index f388b6309308fe9db03075f3918a801036146a8b..f871551289b193c962ce74cd60382ebf4af1008a 100644 (file)
@@ -79,7 +79,10 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs):
     # node.includes - the result of include_re.findall()
 
     if not hasattr(target, 'cpppath'):
-        def Dir(x, dir=target.cwd, fs=fs): return fs.Dir(x,dir)
+        def Dir(rep, path, dir=target.cwd, fs=fs):
+            if rep:
+                path = os.path.join(rep, path)
+            return fs.Dir(path, dir)
         try:
             target.cpppath = tuple(fs.Rsearchall(env['CPPPATH'], Dir))
         except KeyError:
index e87b885d19cbbe7854816c5ef2c27624774bafeb..954510ac641d30b4392e22fbcfcb6379b7728f68 100644 (file)
@@ -77,7 +77,10 @@ def scan(node, env, target, fs = SCons.Node.FS.default_fs):
     # node.includes - the result of include_re.findall()
 
     if not hasattr(target, 'f77path'):
-        def Dir(x, dir=target.cwd, fs=fs): return fs.Dir(x,dir)
+        def Dir(rep, path, dir=target.cwd, fs=fs):
+            if rep:
+                path = os.path.join(rep, path)
+            return fs.Dir(path, dir)
         try:
             target.f77path = tuple(fs.Rsearchall(env['F77PATH'], Dir))
         except KeyError: