summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Scanner/__init__.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-09-15 01:45:17 (GMT)
committerSteven Knight <knight@baldmt.com>2002-09-15 01:45:17 (GMT)
commitb04744713085a486615cbef5f489dc522988fb36 (patch)
tree2bac76ddc5252e4e37c6f5df0738278d1b2aa6d5 /src/engine/SCons/Scanner/__init__.py
parent37d6dd7bf93de0e1cbd5382cd7687ff5294183ec (diff)
downloadSCons-b04744713085a486615cbef5f489dc522988fb36.zip
SCons-b04744713085a486615cbef5f489dc522988fb36.tar.gz
SCons-b04744713085a486615cbef5f489dc522988fb36.tar.bz2
Provide a Scanner hook to allow file scans to be avoided when it isn't necessary.
Diffstat (limited to 'src/engine/SCons/Scanner/__init__.py')
-rw-r--r--src/engine/SCons/Scanner/__init__.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py
index 28159c9..dc10648 100644
--- a/src/engine/SCons/Scanner/__init__.py
+++ b/src/engine/SCons/Scanner/__init__.py
@@ -52,7 +52,8 @@ class Base:
name = "NONE",
argument = _null,
skeys = [],
- node_factory = SCons.Node.FS.default_fs.File):
+ node_factory = SCons.Node.FS.default_fs.File,
+ scan_check = None):
"""
Construct a new scanner object given a scanner function.
@@ -77,7 +78,7 @@ class Base:
Examples:
s = Scanner(my_scanner_function)
-
+
s = Scanner(function = my_scanner_function)
s = Scanner(function = my_scanner_function, argument = 'foo')
@@ -94,6 +95,7 @@ class Base:
self.argument = argument
self.skeys = skeys
self.node_factory = node_factory
+ self.scan_check = scan_check
def scan(self, node, env, target):
"""
@@ -102,6 +104,8 @@ class Base:
environment that will be passed to the scanner function. A list of
direct dependency nodes for the specified node will be returned.
"""
+ if self.scan_check and not self.scan_check(node):
+ return []
if not self.argument is _null:
list = self.function(node, env, target, self.argument)
@@ -123,7 +127,17 @@ class Base:
def __hash__(self):
return hash(None)
-class Recursive(Base):
+class RExists(Base):
+ """
+ Scan a node only if it exists (locally or in a Repository).
+ """
+ def __init__(self, *args, **kw):
+ def rexists_check(node):
+ return node.rexists()
+ kw['scan_check'] = rexists_check
+ apply(Base.__init__, (self,) + args, kw)
+
+class Recursive(RExists):
"""
The class for recursive dependency scanning. This will
re-scan any new files returned by each call to the