t.set_executor(executor)
if builder.scanner:
t.target_scanner = builder.scanner
- if not hasattr(t, 'source_scanner'):
+ if not t.source_scanner:
t.source_scanner = env.get_scanner(t.scanner_key())
# Last, add scanners from the Environment to the source Nodes.
for s in slist:
- if not hasattr(s, 'source_scanner'):
- s.source_scanner = env.get_scanner(s.scanner_key())
+ if not s.source_scanner:
+ s.source_scanner = env.get_scanner(s.scanner_key())
class EmitterProxy:
"""This is a callable class that can act as a
outfile2 = test.workpath('outfile2')
show_string = None
-env_scanner = None
scons_env = SCons.Environment.Environment()
self.d[k] = v
global env_arg2nodes_called
env_arg2nodes_called = None
+ self.scanner = None
def subst(self, s):
if not SCons.Util.is_String(s):
return s
list.append(a)
return list
def get_scanner(self, ext):
- return env_scanner
+ return self.scanner
def Dictionary(self):
return {}
def autogenerate(self, dir=''):
self.sources = []
self.builder = None
self.side_effect = 0
+ self.source_scanner = None
def __str__(self):
return self.name
def builder_set(self, builder):
def test_src_scanner(slf):
"""Testing ability to set a source file scanner through a builder."""
- global env_scanner
class TestScanner:
def key(self, env):
return 'TestScannerkey'
def instance(self, env):
return self
- env_scanner = TestScanner()
- env = Environment()
+
+ scanner = TestScanner()
builder = SCons.Builder.Builder(action='action')
- tgt = builder(env, target='foo.x', source='bar.y')
+
+ # With no scanner specified, source_scanner is None.
+ env1 = Environment()
+ tgt = builder(env1, target='foo1.x', source='bar.y')
+ src = tgt.sources[0]
+ assert tgt.target_scanner != scanner, tgt.target_scanner
+ assert src.source_scanner is None, src.source_scanner
+
+ # Later use of the same source file with an environment that
+ # has a scanner must still set the scanner.
+ env2 = Environment()
+ env2.scanner = scanner
+ tgt = builder(env2, target='foo2.x', source='bar.y')
src = tgt.sources[0]
- assert tgt.target_scanner != env_scanner, tgt.target_scanner
- assert src.source_scanner == env_scanner, src.source_scanner
+ assert tgt.target_scanner != scanner, tgt.target_scanner
+ assert src.source_scanner == scanner, src.source_scanner
def test_Builder_Args(self):
"""Testing passing extra args to a builder."""
self.parents = {}
self.wkids = None # Kids yet to walk, when it's an array
self.target_scanner = None # explicit scanner from this node's Builder
-
- # If/when this attribute exists, it's an implicit scanner from
- # the scanner map for an environment. The attribute is created
- # when we select the scanner, a value of None means there is none.
- #self.source_scanner = None
+ self.source_scanner = None # source scanner
self.env = None
self.state = None
# Clear out the implicit dependency caches:
# XXX this really should somehow be made more general and put
# under the control of the scanners.
- try:
- scanner = self.source_scanner
- except AttributeError:
- pass
- else:
- if scanner:
- self.found_includes = {}
- self.includes = None
+ if self.source_scanner:
+ self.found_includes = {}
+ self.includes = None
- def get_parents(node, parent): return node.get_parents()
- def clear_cache(node, parent):
- node.implicit = None
- node.del_bsig()
- w = Walker(self, get_parents, ignore_cycle, clear_cache)
- while w.next(): pass
+ def get_parents(node, parent): return node.get_parents()
+ def clear_cache(node, parent):
+ node.implicit = None
+ node.del_bsig()
+ w = Walker(self, get_parents, ignore_cycle, clear_cache)
+ while w.next(): pass
# clear out the content signature, since the contents of this
# node were presumably just changed:
build_env = self.get_build_env()
for child in self.children(scan=0):
- try:
- scanner = child.source_scanner
- except AttributeError:
- pass
- else:
- if scanner:
- self._add_child(self.implicit,
- self.implicit_dict,
- child.get_implicit_deps(build_env,
- scanner,
- self))
+ scanner = child.source_scanner
+ if scanner:
+ self._add_child(self.implicit,
+ self.implicit_dict,
+ child.get_implicit_deps(build_env,
+ scanner,
+ self))
# scan this node itself for implicit dependencies
self._add_child(self.implicit,