diff options
author | Steven Knight <knight@baldmt.com> | 2001-12-04 06:42:41 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-12-04 06:42:41 (GMT) |
commit | a12957948f90147743ecf2368a9a348c8619a09b (patch) | |
tree | 03180d9350c36bde99cdfff8136a0c9a96c76a43 /src | |
parent | 7543ec6ef46cd3fe5e7861e4c5167a4c562ac92b (diff) | |
download | SCons-a12957948f90147743ecf2368a9a348c8619a09b.zip SCons-a12957948f90147743ecf2368a9a348c8619a09b.tar.gz SCons-a12957948f90147743ecf2368a9a348c8619a09b.tar.bz2 |
Speed up and generalize SCons.Util.find_files().
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Scanner/C.py | 14 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/Prog.py | 4 | ||||
-rw-r--r-- | src/engine/SCons/Util.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/UtilTests.py | 4 |
4 files changed, 20 insertions, 13 deletions
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py index 7396125..ab48342 100644 --- a/src/engine/SCons/Scanner/C.py +++ b/src/engine/SCons/Scanner/C.py @@ -66,8 +66,10 @@ def scan(filename, env, node_factory): dependencies. """ + fs = SCons.Node.FS.default_fs try: - paths = env.Dictionary("CPPPATH") + paths = map(lambda x, dir=fs.Dir: dir(x), + env.Dictionary("CPPPATH")) except KeyError: paths = [] @@ -79,11 +81,15 @@ def scan(filename, env, node_factory): angle_includes = angle_re.findall(contents) quote_includes = quote_re.findall(contents) - source_dir = os.path.dirname(filename) + dir = os.path.dirname(filename) + if dir: + source_dir = [fs.Dir(dir)] + else: + source_dir = [] - return (SCons.Util.find_files(angle_includes, paths + [source_dir], + return (SCons.Util.find_files(angle_includes, paths + source_dir, node_factory) - + SCons.Util.find_files(quote_includes, [source_dir] + paths, + + SCons.Util.find_files(quote_includes, source_dir + paths, node_factory)) except OSError: return [] diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 0f8acff..cbbfb42 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -40,8 +40,10 @@ def scan(filename, env, node_factory): files it finds as dependencies. """ + fs = SCons.Node.FS.default_fs try: - paths = env.Dictionary("LIBPATH") + paths = map(lambda x, dir=fs.Dir: dir(x), + env.Dictionary("LIBPATH")) except KeyError: paths = [] diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 1d42d18..9108f14 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -228,22 +228,21 @@ def find_files(filenames, paths, find_files([str], [str]) -> [nodes] filenames - a list of filenames to find - paths - a list of paths to search in + paths - a list of directory path *nodes* to search in returns - the nodes created from the found files. Finds nodes corresponding to either derived files or files that exist already. - Only the first fullname found is returned for each filename, and any - file that aren't found are ignored. + Only the first file found is returned for each filename, + and any files that aren't found are ignored. """ nodes = [] for filename in filenames: - for path in paths: - fullname = os.path.join(path, filename) + for dir in paths: try: - node = node_factory(fullname) + node = node_factory(filename, dir) # Return true of the node exists or is a derived node. if node.builder or \ (isinstance(node, SCons.Node.FS.Entry) and node.exists()): diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index e8a6eca..58e81b5 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -167,8 +167,8 @@ class UtilTestCase(unittest.TestCase): fs = SCons.Node.FS.FS(test.workpath("")) node_derived = fs.File(test.workpath('./bar/baz')) node_derived.builder_set(1) # Any non-zero value. - nodes = find_files(['foo', 'baz'], - map(test.workpath, ['./', './bar' ]), fs.File) + paths = map(lambda x, fs=fs: fs.Dir(x), ['./', './bar']) + nodes = find_files(['foo', 'baz'], paths, fs.File) file_names = map(str, nodes) file_names = map(os.path.normpath, file_names) assert os.path.normpath('./foo') in file_names, file_names |