summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-12-27 22:24:55 (GMT)
committerSteven Knight <knight@baldmt.com>2005-12-27 22:24:55 (GMT)
commitb03e7ab4ca681e521249cfed7a727299c76378db (patch)
treeacaae981ff2f6ce27cbf760c83b113f76129705e /src/engine/SCons/Node
parent0859903f99927abc0383b2e642d060604d5f9695 (diff)
downloadSCons-b03e7ab4ca681e521249cfed7a727299c76378db.zip
SCons-b03e7ab4ca681e521249cfed7a727299c76378db.tar.gz
SCons-b03e7ab4ca681e521249cfed7a727299c76378db.tar.bz2
Handle scanning of the in-memory entries for a Dir with a scanner, not a hard-coded Python method.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r--src/engine/SCons/Node/Alias.py2
-rw-r--r--src/engine/SCons/Node/FS.py22
-rw-r--r--src/engine/SCons/Node/FSTests.py54
-rw-r--r--src/engine/SCons/Node/NodeTests.py23
-rw-r--r--src/engine/SCons/Node/__init__.py9
5 files changed, 65 insertions, 45 deletions
diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py
index bc7e53b..e023ab7 100644
--- a/src/engine/SCons/Node/Alias.py
+++ b/src/engine/SCons/Node/Alias.py
@@ -76,7 +76,7 @@ class Alias(SCons.Node.Node):
def get_contents(self):
"""The contents of an alias is the concatenation
of all the contents of its sources"""
- contents = map(lambda n: n.get_contents(), self.children(None))
+ contents = map(lambda n: n.get_contents(), self.children())
return string.join(contents, '')
def sconsign(self):
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 59ad707..69936d2 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -198,12 +198,14 @@ def get_MkdirBuilder():
global MkdirBuilder
if MkdirBuilder is None:
import SCons.Builder
+ import SCons.Defaults
# "env" will get filled in by Executor.get_build_env()
# calling SCons.Defaults.DefaultEnvironment() when necessary.
MkdirBuilder = SCons.Builder.Builder(action = Mkdir,
env = None,
explain = None,
is_explicit = None,
+ target_scanner = SCons.Defaults.DirEntryScanner,
name = "MkdirBuilder")
return MkdirBuilder
@@ -1287,21 +1289,11 @@ class Dir(Base):
return string.join(path_elems, os.sep)
- def scan(self):
- if not self.implicit is None:
- return
- self.implicit = []
- self.implicit_dict = {}
- self._children_reset()
+ def get_env_scanner(self, env, kw={}):
+ return SCons.Defaults.DirEntryScanner
- dont_scan = lambda k: k not in ['.', '..', '.sconsign']
- deps = filter(dont_scan, self.entries.keys())
- # keys() is going to give back the entries in an internal,
- # unsorted order. Sort 'em so the order is deterministic.
- deps.sort()
- entries = map(lambda n, e=self.entries: e[n], deps)
-
- self._add_child(self.implicit, self.implicit_dict, entries)
+ def get_target_scanner(self):
+ return SCons.Defaults.DirEntryScanner
def get_found_includes(self, env, scanner, path):
"""Return the included implicit dependencies in this file.
@@ -1310,7 +1302,7 @@ class Dir(Base):
__cacheable__"""
if not scanner:
return []
- # Clear cached info for this Node. If we already visited this
+ # Clear cached info for this Dir. If we already visited this
# directory on our walk down the tree (because we didn't know at
# that point it was being used as the source for another Node)
# then we may have calculated build signature before realizing
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index ba6cea8..8c95f87 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -966,22 +966,6 @@ class FSTestCase(_tempdirTestCase):
dir = fs.Dir(drive)
assert str(dir) == drive + os.sep, str(dir)
- # Test Dir.scan()
- dir = fs.Dir('ddd')
- fs.File(string.join(['ddd', 'f1'], sep))
- fs.File(string.join(['ddd', 'f2'], sep))
- fs.File(string.join(['ddd', 'f3'], sep))
- fs.Dir(string.join(['ddd', 'd1'], sep))
- fs.Dir(string.join(['ddd', 'd1', 'f4'], sep))
- fs.Dir(string.join(['ddd', 'd1', 'f5'], sep))
- dir.scan()
- kids = map(lambda x: x.path, dir.children(None))
- kids.sort()
- assert kids == [os.path.join('ddd', 'd1'),
- os.path.join('ddd', 'f1'),
- os.path.join('ddd', 'f2'),
- os.path.join('ddd', 'f3')], kids
-
# Test for a bug in 0.04 that did not like looking up
# dirs with a trailing slash on Win32.
d=fs.Dir('./')
@@ -1366,7 +1350,7 @@ class FSTestCase(_tempdirTestCase):
assert str(t) == 'pre-z-suf', str(t)
def test_same_name(self):
- """Test that a local same-named file isn't found for # Dir lookup"""
+ """Test that a local same-named file isn't found for a Dir lookup"""
test = self.test
fs = self.fs
@@ -1485,6 +1469,42 @@ class DirTestCase(_tempdirTestCase):
assert a[0] == 'pre', a
assert a[2] == 'post', a
+ def test_get_env_scanner(self):
+ """Test the Dir.get_env_scanner() method
+ """
+ import SCons.Defaults
+ d = self.fs.Dir('ddd')
+ s = d.get_env_scanner(Environment())
+ assert s is SCons.Defaults.DirEntryScanner, s
+
+ def test_get_target_scanner(self):
+ """Test the Dir.get_target_scanner() method
+ """
+ import SCons.Defaults
+ d = self.fs.Dir('ddd')
+ s = d.get_target_scanner()
+ assert s is SCons.Defaults.DirEntryScanner, s
+
+ def test_scan(self):
+ """Test scanning a directory for in-memory entries
+ """
+ fs = self.fs
+
+ dir = fs.Dir('ddd')
+ fs.File(os.path.join('ddd', 'f1'))
+ fs.File(os.path.join('ddd', 'f2'))
+ fs.File(os.path.join('ddd', 'f3'))
+ fs.Dir(os.path.join('ddd', 'd1'))
+ fs.Dir(os.path.join('ddd', 'd1', 'f4'))
+ fs.Dir(os.path.join('ddd', 'd1', 'f5'))
+ dir.scan()
+ kids = map(lambda x: x.path, dir.children(None))
+ kids.sort()
+ assert kids == [os.path.join('ddd', 'd1'),
+ os.path.join('ddd', 'f1'),
+ os.path.join('ddd', 'f2'),
+ os.path.join('ddd', 'f3')], kids
+
def test_entry_exists_on_disk(self):
"""Test the Dir.entry_exists_on_disk() method
"""
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index 3e2fd5c..1cd5201 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -930,17 +930,28 @@ class NodeTestCase(unittest.TestCase):
deps = node.get_implicit_deps(env, s, target)
assert deps == [d1, d2], map(str, deps)
- def test_get_scanner(self):
+ def test_get_env_scanner(self):
"""Test fetching the environment scanner for a Node
"""
node = SCons.Node.Node()
scanner = Scanner()
env = Environment(SCANNERS = [scanner])
- s = node.get_scanner(env)
+ s = node.get_env_scanner(env)
assert s == scanner, s
- s = node.get_scanner(env, {'X':1})
+ s = node.get_env_scanner(env, {'X':1})
assert s == scanner, s
+ def test_get_target_scanner(self):
+ """Test fetching the target scanner for a Node
+ """
+ s = Scanner()
+ b = Builder()
+ b.target_scanner = s
+ n = SCons.Node.Node()
+ n.builder = b
+ x = n.get_target_scanner()
+ assert x is s, x
+
def test_get_source_scanner(self):
"""Test fetching the source scanner for a Node
"""
@@ -1044,12 +1055,6 @@ class NodeTestCase(unittest.TestCase):
"""Test that a scanner_key() method exists"""
assert SCons.Node.Node().scanner_key() == None
- def test_select_scanner(self):
- """Test the base select_scanner() method returns its scanner"""
- scanner = Scanner()
- s = SCons.Node.Node().select_scanner(scanner)
- assert scanner is s, s
-
def test_children(self):
"""Test fetching the non-ignored "children" of a Node.
"""
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 7a29f95..250c714 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -474,9 +474,12 @@ class Node:
return deps
- def get_scanner(self, env, kw={}):
+ def get_env_scanner(self, env, kw={}):
return env.get_scanner(self.scanner_key())
+ def get_target_scanner(self):
+ return self.builder.target_scanner
+
def get_source_scanner(self, node):
"""Fetch the source scanner for the specified node
@@ -498,7 +501,7 @@ class Node:
# The builder didn't have an explicit scanner, so go look up
# a scanner from env['SCANNERS'] based on the node's scanner
# key (usually the file extension).
- scanner = self.get_scanner(self.get_build_env())
+ scanner = self.get_env_scanner(self.get_build_env())
if scanner:
scanner = scanner.select(node)
return scanner
@@ -563,7 +566,7 @@ class Node:
# If there's a target scanner, have the executor scan the target
# node itself and associated targets that might be built.
- scanner = self.builder.target_scanner
+ scanner = self.get_target_scanner()
if scanner:
executor.scan_targets(scanner)