summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-10-09 03:23:36 (GMT)
committerSteven Knight <knight@baldmt.com>2004-10-09 03:23:36 (GMT)
commit759d82c0b890501e19708536e47d83e00c6dae09 (patch)
treee0e0d0df134f2f47857e0a202e6ea95e78552889 /src/engine/SCons/Node
parent08a678fdf7348b3d8df254225eb563d4a5ad6022 (diff)
downloadSCons-759d82c0b890501e19708536e47d83e00c6dae09.zip
SCons-759d82c0b890501e19708536e47d83e00c6dae09.tar.gz
SCons-759d82c0b890501e19708536e47d83e00c6dae09.tar.bz2
Win32 portability fixes for tests.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r--src/engine/SCons/Node/FS.py2
-rw-r--r--src/engine/SCons/Node/FSTests.py3
-rw-r--r--src/engine/SCons/Node/NodeTests.py46
-rw-r--r--src/engine/SCons/Node/__init__.py21
4 files changed, 25 insertions, 47 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 947963f..2bd68e1 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1769,7 +1769,7 @@ class File(Base):
return csig
- def current(self, calc=None):
+ def current(self, calc=None, scan=1):
self.binfo = self.gen_binfo(calc)
if self.always_build:
return None
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index ebaf3b9..2259b7b 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -93,7 +93,6 @@ class Builder:
self.env = Environment()
self.overrides = {}
self.action = action
- self.target_scanner = None
def targets(self, t):
return [t]
@@ -802,7 +801,7 @@ class FSTestCase(unittest.TestCase):
f1.builder_set(Builder(fs.File))
f1.env_set(Environment())
xyz = fs.File("xyz")
- f1.builder.target_scanner = Scanner(xyz)
+ f1.target_scanner = Scanner(xyz)
f1.scan()
assert f1.implicit[0].path == "xyz"
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index b9b1b1f..f8cd62b 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -91,18 +91,12 @@ class Environment:
return apply(Environment, (), d)
def _update(self, dict):
self._dict.update(dict)
- def get_calculator(self):
- return SCons.Sig.default_calc
- def get_scanner(self, scanner_key):
- return self._dict['SCANNERS'][0]
class Builder:
- def __init__(self, env=None):
- if env is None: env = Environment()
- self.env = env
+ def __init__(self):
+ self.env = Environment()
self.overrides = {}
self.action = MyAction()
- self.source_factory = MyNode
def targets(self, t):
return [t]
def get_actions(self):
@@ -710,6 +704,8 @@ class NodeTestCase(unittest.TestCase):
def test_get_source_scanner(self):
"""Test fetching the source scanner for a Node
"""
+ class Builder:
+ pass
target = SCons.Node.Node()
source = SCons.Node.Node()
s = target.get_source_scanner(source)
@@ -719,34 +715,19 @@ class NodeTestCase(unittest.TestCase):
ts2 = Scanner()
ts3 = Scanner()
- class Builder1(Builder):
- def __call__(self, source):
- r = SCons.Node.Node()
- r.builder = self
- return [r]
- class Builder2 (Builder1):
- def __init__(self, source_scanner):
- self.source_scanner = source_scanner
-
- builder = Builder2(ts1)
-
- targets = builder([source])
- s = targets[0].get_source_scanner(source)
+ source.backup_source_scanner = ts1
+ s = target.get_source_scanner(source)
assert s is ts1, s
- target.builder_set(Builder2(ts1))
+ target.builder = Builder()
target.builder.source_scanner = ts2
s = target.get_source_scanner(source)
assert s is ts2, s
- builder = Builder1(env=Environment(SCANNERS = [ts3]))
-
- targets = builder([source])
-
- s = targets[0].get_source_scanner(source)
+ target.source_scanner = ts3
+ s = target.get_source_scanner(source)
assert s is ts3, s
-
def test_scan(self):
"""Test Scanner functionality
"""
@@ -758,7 +739,8 @@ class NodeTestCase(unittest.TestCase):
d = MyNode("ddd")
node.found_includes = [d]
- node.builder.target_scanner = s
+ assert node.target_scanner == None, node.target_scanner
+ node.target_scanner = s
assert node.implicit is None
node.scan()
@@ -791,14 +773,12 @@ class NodeTestCase(unittest.TestCase):
try:
sn = StoredNode("eee")
sn._children = ['fake']
- sn.builder_set(Builder())
- sn.builder.target_scanner = s
+ sn.target_scanner = s
sn.scan()
assert sn.implicit == [], sn.implicit
- assert sn._children == [], sn._children
-
+ assert not hasattr(sn, '_children'), "unexpected _children attribute"
finally:
SCons.Sig.default_calc = save_default_calc
SCons.Node.implicit_cache = save_implicit_cache
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 27e185e..338df07 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -67,7 +67,7 @@ executed = 4
failed = 5
stack = 6 # nodes that are in the current Taskmaster execution stack
-# controls whether implicit dependencies are cached:
+# controls whether implicit depedencies are cached:
implicit_cache = 0
# controls whether implicit dep changes are ignored:
@@ -118,6 +118,9 @@ class Node:
self.implicit = None # implicit (scanned) dependencies (None means not scanned yet)
self.waiting_parents = []
self.wkids = None # Kids yet to walk, when it's an array
+ self.target_scanner = None # explicit scanner from this node's Builder
+ self.source_scanner = None
+ self.backup_source_scanner = None
self.env = None
self.state = None
@@ -399,17 +402,15 @@ class Node:
NOTE: "self" is the target being built, "node" is
the source file for which we want to fetch the scanner.
"""
- if not self.has_builder():
- return None # if not buildable, can't have sources...
+ if self.source_scanner:
+ return self.source_scanner
try:
scanner = self.builder.source_scanner
if scanner:
return scanner
except AttributeError:
pass
-
- # No scanner specified by builder, try env['SCANNERS']
- return self.get_build_env().get_scanner(node.scanner_key())
+ return node.backup_source_scanner or None
def scan(self):
"""Scan this node's dependents for implicit dependencies."""
@@ -433,7 +434,7 @@ class Node:
implicit = map(self.implicit_factory, implicit)
self._add_child(self.implicit, self.implicit_dict, implicit)
calc = build_env.get_calculator()
- if implicit_deps_unchanged or self.current(calc):
+ if implicit_deps_unchanged or self.current(calc, scan=0):
return
else:
# one of this node's sources has changed, so
@@ -451,10 +452,8 @@ class Node:
self._add_child(self.implicit, self.implicit_dict, deps)
# scan this node itself for implicit dependencies
- scanner = self.builder.target_scanner
- if scanner:
- deps = self.get_implicit_deps(build_env, scanner, self)
- self._add_child(self.implicit, self.implicit_dict, deps)
+ deps = self.get_implicit_deps(build_env, self.target_scanner, self)
+ self._add_child(self.implicit, self.implicit_dict, deps)
# XXX See note above re: --implicit-cache.
#if implicit_cache: