summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Scanner/__init__.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-05-19 17:49:55 (GMT)
committerSteven Knight <knight@baldmt.com>2004-05-19 17:49:55 (GMT)
commit04ebe107191659f805bd63148c61c1026efeb686 (patch)
tree9122729d1120c1119fe10ff360f4675789ca8f9b /src/engine/SCons/Scanner/__init__.py
parent12d2ae1193b9e32e0164218bb73240791914f976 (diff)
downloadSCons-04ebe107191659f805bd63148c61c1026efeb686.zip
SCons-04ebe107191659f805bd63148c61c1026efeb686.tar.gz
SCons-04ebe107191659f805bd63148c61c1026efeb686.tar.bz2
Fix spurious rebuilds/reinstalls of header files and circular dependencies with generated header files by allowing Scanners to be associated explicitly with Builders, not just through Scanner file suffix lists.
Diffstat (limited to 'src/engine/SCons/Scanner/__init__.py')
-rw-r--r--src/engine/SCons/Scanner/__init__.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py
index 8f6c9e6..8432638 100644
--- a/src/engine/SCons/Scanner/__init__.py
+++ b/src/engine/SCons/Scanner/__init__.py
@@ -43,6 +43,15 @@ class _Null:
# used as an actual argument value.
_null = _Null
+def Scanner(function, *args, **kw):
+ """Public interface factory function for creating different types
+ of Scanners based on the different types of "functions" that may
+ be supplied."""
+ if SCons.Util.is_Dict(function):
+ return apply(Selector, (function,) + args, kw)
+ else:
+ return apply(Base, (function,) + args, kw)
+
class FindPathDirs:
"""A class to bind a specific *PATH variable name and the fs object
to a function that will return all of the *path directories."""
@@ -190,6 +199,31 @@ class Base:
return env.subst_list(self.skeys)[0]
return self.skeys
+ def select(self, node):
+ return self
+
+
+class Selector(Base):
+ """
+ A class for selecting a more specific scanner based on the
+ scanner_key() (suffix) for a specific Node.
+ """
+ def __init__(self, dict, *args, **kw):
+ Base.__init__(self, (None,)+args, kw)
+ self.dict = dict
+
+ def __call__(self, node, env, path = ()):
+ return self.select(node)(node, env, path)
+
+ def select(self, node):
+ try:
+ return self.dict[node.scanner_key()]
+ except KeyError:
+ return None
+
+ def add_scanner(self, skey, scanner):
+ self.dict[skey] = scanner
+
class Current(Base):
"""
@@ -200,6 +234,7 @@ class Current(Base):
def __init__(self, *args, **kw):
def current_check(node, env):
+ calc = env.get_calculator()
c = not node.has_builder() or node.current(env.get_calculator())
return c
kw['scan_check'] = current_check