summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Scanner/C.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Scanner/C.py')
-rw-r--r--src/engine/SCons/Scanner/C.py55
1 files changed, 18 insertions, 37 deletions
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py
index 0d74dc5..e2842e1 100644
--- a/src/engine/SCons/Scanner/C.py
+++ b/src/engine/SCons/Scanner/C.py
@@ -33,6 +33,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import SCons.Scanner
import re
import os.path
+import SCons.Util
angle_re = re.compile('^[ \t]*#[ \t]*include[ \t]+<([\\w./\\\\]+)>', re.M)
quote_re = re.compile('^[ \t]*#[ \t]*include[ \t]+"([\\w./\\\\]+)"', re.M)
@@ -44,28 +45,6 @@ def CScan():
s.name = "CScan"
return s
-def find_files(filenames, paths):
- """
- find_files([str], [str]) -> [str]
-
- filenames - a list of filenames to find
- paths - a list of paths to search in
-
- returns - the fullnames of the files
-
- Only the first fullname found is returned for each filename, and any
- file that aren't found are ignored.
- """
- fullnames = []
- for filename in filenames:
- for path in paths:
- fullname = os.path.join(path, filename)
- if os.path.exists(fullname):
- fullnames.append(fullname)
- break
-
- return fullnames
-
def scan(filename, env, node_factory):
"""
scan(str, Environment) -> [str]
@@ -87,22 +66,24 @@ def scan(filename, env, node_factory):
dependencies.
"""
- if hasattr(env, "CPPPATH"):
- paths = env.CPPPATH
- else:
+ try:
+ paths = env.Dictionary("CPPPATH")
+ except KeyError:
paths = []
-
- file = open(filename)
- contents = file.read()
- file.close()
- angle_includes = angle_re.findall(contents)
- quote_includes = quote_re.findall(contents)
+ try:
+ file = open(filename)
+ contents = file.read()
+ file.close()
- source_dir = os.path.dirname(filename)
-
- deps = (find_files(angle_includes, paths + [source_dir])
- + find_files(quote_includes, [source_dir] + paths))
+ angle_includes = angle_re.findall(contents)
+ quote_includes = quote_re.findall(contents)
- deps = map(node_factory, deps)
- return deps
+ source_dir = os.path.dirname(filename)
+
+ return (SCons.Util.find_files(angle_includes, paths + [source_dir],
+ node_factory)
+ + SCons.Util.find_files(quote_includes, [source_dir] + paths,
+ node_factory))
+ except OSError:
+ return []