diff options
author | William Blevins <wblevins@gmail.com> | 2015-06-30 03:32:45 (GMT) |
---|---|---|
committer | William Blevins <wblevins@gmail.com> | 2015-06-30 03:32:45 (GMT) |
commit | e5ac090e378fd5cda31dd70f762ea2792eed7dc7 (patch) | |
tree | e4ffce8474a2f0b101410a476472ae5dc550fbbc /src/engine/SCons/Node | |
parent | 5260437c85052289702664c6a1025202eaf7111a (diff) | |
download | SCons-e5ac090e378fd5cda31dd70f762ea2792eed7dc7.zip SCons-e5ac090e378fd5cda31dd70f762ea2792eed7dc7.tar.gz SCons-e5ac090e378fd5cda31dd70f762ea2792eed7dc7.tar.bz2 |
Issue 2264: Updated behaviour when scanning included dependencies for nodes without scanner_key mappings.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 2 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 63 |
2 files changed, 47 insertions, 18 deletions
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 4639cf9..1478419 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -121,6 +121,8 @@ class Environment(object): self._dict.update(kw) def __getitem__(self, key): return self._dict[key] + def get(self, key, default = None): + return self._dict.get(key, default) def Dictionary(self, *args): return {} def Override(self, overrides): diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 5721442..64a513b 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -916,7 +916,7 @@ class Node(object): """ return [] - def get_implicit_deps(self, env, scanner, path, kw = {}): + def get_implicit_deps(self, env, initial_scanner, path_func, kw = {}): """Return a list of implicit dependencies for this node. This method exists to handle recursive invocation of the scanner @@ -926,31 +926,58 @@ class Node(object): nodes = [self] seen = {} seen[self] = 1 - deps = [] + dependencies = [] + + root_node_scanner = self._get_scanner(env, initial_scanner, None, kw) + while nodes: - n = nodes.pop(0) + node = nodes.pop(0) - if not scanner: - s = n.get_env_scanner(env, kw) - if s: - s = s.select(n) - else: - s = scanner.select(n) + scanner = node._get_scanner(env, initial_scanner, root_node_scanner, kw) - if not s: + if not scanner: continue - p = path(s) + path = path_func(scanner) - d = [x for x in n.get_found_includes(env, s, p) if x not in seen] - if d: - deps.extend(d) - for n in d: - seen[n] = 1 - nodes.extend(s.recurse_nodes(d)) + included_deps = [x for x in node.get_found_includes(env, scanner, path) if x not in seen] + if included_deps: + dependencies.extend(included_deps) + for dep in included_deps: + seen[dep] = 1 + nodes.extend(scanner.recurse_nodes(included_deps)) - return deps + return dependencies + def _get_scanner(self, env, initial_scanner, root_node_scanner, kw): + if not initial_scanner: + # handle implicit scanner case + scanner = self.get_env_scanner(env, kw) + if scanner: + scanner = scanner.select(self) + else: + # handle explicit scanner case + scanner = initial_scanner.select(self) + + if not scanner: + # no scanner could be found for the given node's scanner key; + # thus, make an attempt at using a default. + + # check for a user specified scanner hint + scanner = env.get( 'SCANNER_HINT' ) + + if scanner: + # Ensure scanner hint returned a valid Scanner object + if not instanceof( scanner, SCons.Scanner.Base ): + raise SCons.Error.UserError( + 'SCANNER_HINT object must be instance of ' + str(SCons.Scanner.Base) + ) + else: + # no scanner hint, so do best guess (IE. return the root's scanner). + scanner = root_node_scanner + + return scanner + def get_env_scanner(self, env, kw={}): return env.get_scanner(self.scanner_key()) |