summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-08-08 18:22:55 (GMT)
committerSteven Knight <knight@baldmt.com>2002-08-08 18:22:55 (GMT)
commitcf339c049d817d154d838b65808889720f589a04 (patch)
treeae1ef876c89364096fd66d25bafbf0082ac508bb
parent6a5f2b1ff1288ed43ef066b4fde76ef0e7354a56 (diff)
downloadSCons-cf339c049d817d154d838b65808889720f589a04.zip
SCons-cf339c049d817d154d838b65808889720f589a04.tar.gz
SCons-cf339c049d817d154d838b65808889720f589a04.tar.bz2
Refactor the interface between Rsearch() and Rsearchall() and their supplied functions' arguments to keep the repository and dir path portions separate.
-rw-r--r--src/engine/SCons/Environment.py4
-rw-r--r--src/engine/SCons/Node/FS.py16
-rw-r--r--src/engine/SCons/Node/FSTests.py11
-rw-r--r--src/engine/SCons/Scanner/C.py5
-rw-r--r--src/engine/SCons/Scanner/Fortran.py5
5 files changed, 29 insertions, 12 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index fea60c3..4a86ae6 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -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)
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index d438cd0..1c90ea8 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -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
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index b45cc4b..5945f3f 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -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
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py
index f388b63..f871551 100644
--- a/src/engine/SCons/Scanner/C.py
+++ b/src/engine/SCons/Scanner/C.py
@@ -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:
diff --git a/src/engine/SCons/Scanner/Fortran.py b/src/engine/SCons/Scanner/Fortran.py
index e87b885..954510a 100644
--- a/src/engine/SCons/Scanner/Fortran.py
+++ b/src/engine/SCons/Scanner/Fortran.py
@@ -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: