summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2015-11-13 15:01:44 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2015-11-13 15:01:44 (GMT)
commit4a0683af8a414b8143dbc369d59f4349d99089ac (patch)
tree3d4643d1382f4fb3c0cf79b97a7caa10a6023711 /src
parentc2d974ea65afe9ab1968a16c797155fd799527ca (diff)
parent04b306103a2c37b90f2d764112c0cb5527313849 (diff)
downloadSCons-4a0683af8a414b8143dbc369d59f4349d99089ac.zip
SCons-4a0683af8a414b8143dbc369d59f4349d99089ac.tar.gz
SCons-4a0683af8a414b8143dbc369d59f4349d99089ac.tar.bz2
Merged in williamblevins/scons_20150323 (pull request #244)
Diffstat (limited to 'src')
-rw-r--r--src/CHANGES.txt17
-rw-r--r--src/engine/SCons/Defaults.py2
-rw-r--r--src/engine/SCons/Executor.py26
-rw-r--r--src/engine/SCons/ExecutorTests.py4
-rw-r--r--src/engine/SCons/Node/NodeTests.py21
-rw-r--r--src/engine/SCons/Node/__init__.py57
-rw-r--r--src/engine/SCons/Scanner/SWIG.py45
-rw-r--r--src/engine/SCons/Tool/__init__.py7
-rw-r--r--src/engine/SCons/Tool/install.py1
-rw-r--r--src/engine/SCons/Tool/swig.py6
10 files changed, 122 insertions, 64 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 685a6ae..9e9ec42 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -6,17 +6,12 @@
RELEASE VERSION/DATE TO BE FILLED IN LATER
- From John Doe:
-
- - Whatever John Doe did.
-
-
-RELEASE 2.4.2.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
-
- From John Doe:
-
- - Whatever John Doe did.
-
+ From William Blevins:
+ - Added support for cross-language dependency scanning;
+ SCons now respects scanner keys for implicit dependencies.
+ - Resolved missing cross-language dependencies for
+ SWIG bindings (fixes #2264).
+
RELEASE 2.4.1 - Mon, 07 Nov 2015 10:37:21 -0700
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index 744da5f..c1bd902 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -493,7 +493,7 @@ def __libversionflags(env, version_var, flags_var):
ConstructionEnvironment = {
'BUILDERS' : {},
- 'SCANNERS' : [],
+ 'SCANNERS' : [ SCons.Tool.SourceFileScanner ],
'CONFIGUREDIR' : '#/.sconf_temp',
'CONFIGURELOG' : '#/config.log',
'CPPSUFFIXES' : SCons.Tool.CSuffixes,
diff --git a/src/engine/SCons/Executor.py b/src/engine/SCons/Executor.py
index 98ed758..59e57e3 100644
--- a/src/engine/SCons/Executor.py
+++ b/src/engine/SCons/Executor.py
@@ -486,29 +486,15 @@ class Executor(object):
each individual target, which is a hell of a lot more efficient.
"""
env = self.get_build_env()
+ path = self.get_build_scanner_path
+ kw = self.get_kw()
# TODO(batch): scan by batches)
deps = []
- if scanner:
- for node in node_list:
- node.disambiguate()
- s = scanner.select(node)
- if not s:
- continue
- path = self.get_build_scanner_path(s)
- deps.extend(node.get_implicit_deps(env, s, path))
- else:
- kw = self.get_kw()
- for node in node_list:
- node.disambiguate()
- scanner = node.get_env_scanner(env, kw)
- if not scanner:
- continue
- scanner = scanner.select(node)
- if not scanner:
- continue
- path = self.get_build_scanner_path(scanner)
- deps.extend(node.get_implicit_deps(env, scanner, path))
+
+ for node in node_list:
+ node.disambiguate()
+ deps.extend(node.get_implicit_deps(env, scanner, path, kw))
deps.extend(self.get_implicit_deps())
diff --git a/src/engine/SCons/ExecutorTests.py b/src/engine/SCons/ExecutorTests.py
index 9df0b2d..f390319 100644
--- a/src/engine/SCons/ExecutorTests.py
+++ b/src/engine/SCons/ExecutorTests.py
@@ -83,7 +83,9 @@ class MyNode(object):
executor(self)
def get_env_scanner(self, env, kw):
return MyScanner('dep-')
- def get_implicit_deps(self, env, scanner, path):
+ def get_implicit_deps(self, env, scanner, path, kw={}):
+ if not scanner:
+ scanner = self.get_env_scanner(env, kw)
return [scanner.prefix + str(self)]
def add_to_implicit(self, deps):
self.implicit.extend(deps)
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index a6471b4..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):
@@ -132,7 +134,12 @@ class Environment(object):
def get_factory(self, factory):
return factory or MyNode
def get_scanner(self, scanner_key):
- return self._dict['SCANNERS'][0]
+ try:
+ return self._dict['SCANNERS'][0]
+ except:
+ pass
+
+ return []
class Builder(object):
def __init__(self, env=None, is_explicit=1):
@@ -185,7 +192,7 @@ class Scanner(object):
def __call__(self, node):
self.called = 1
return node.GetTag('found_includes')
- def path(self, env, dir, target=None, source=None):
+ def path(self, env, dir=None, target=None, source=None, kw={}):
return ()
def select(self, node):
return self
@@ -928,7 +935,7 @@ class NodeTestCase(unittest.TestCase):
node.Tag('found_includes', [d1, d2])
# Simple return of the found includes
- deps = node.get_implicit_deps(env, s, target)
+ deps = node.get_implicit_deps(env, s, s.path)
assert deps == [d1, d2], deps
# By default, our fake scanner recurses
@@ -938,24 +945,24 @@ class NodeTestCase(unittest.TestCase):
d1.Tag('found_includes', [e, f])
d2.Tag('found_includes', [e, f])
f.Tag('found_includes', [g])
- deps = node.get_implicit_deps(env, s, target)
+ deps = node.get_implicit_deps(env, s, s.path)
assert deps == [d1, d2, e, f, g], list(map(str, deps))
# Recursive scanning eliminates duplicates
e.Tag('found_includes', [f])
- deps = node.get_implicit_deps(env, s, target)
+ deps = node.get_implicit_deps(env, s, s.path)
assert deps == [d1, d2, e, f, g], list(map(str, deps))
# Scanner method can select specific nodes to recurse
def no_fff(nodes):
return [n for n in nodes if str(n)[0] != 'f']
s.recurse_nodes = no_fff
- deps = node.get_implicit_deps(env, s, target)
+ deps = node.get_implicit_deps(env, s, s.path)
assert deps == [d1, d2, e, f], list(map(str, deps))
# Scanner method can short-circuit recursing entirely
s.recurse_nodes = lambda nodes: []
- deps = node.get_implicit_deps(env, s, target)
+ deps = node.get_implicit_deps(env, s, s.path)
assert deps == [d1, d2], list(map(str, deps))
def test_get_env_scanner(self):
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index f2d37c2..5aa9600 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -916,35 +916,56 @@ class Node(object):
"""
return []
- def get_implicit_deps(self, env, scanner, path):
+ 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
on the implicit dependencies returned by the scanner, if the
scanner's recursive flag says that we should.
"""
- if not scanner:
- return []
-
- # Give the scanner a chance to select a more specific scanner
- # for this Node.
- #scanner = scanner.select(self)
-
nodes = [self]
seen = {}
seen[self] = 1
- deps = []
- while nodes:
- n = nodes.pop(0)
- d = [x for x in n.get_found_includes(env, scanner, path) if x not in seen]
- if d:
- deps.extend(d)
- for n in d:
- seen[n] = 1
- nodes.extend(scanner.recurse_nodes(d))
+ dependencies = []
- return deps
+ root_node_scanner = self._get_scanner(env, initial_scanner, None, kw)
+ while nodes:
+ node = nodes.pop(0)
+
+ scanner = node._get_scanner(env, initial_scanner, root_node_scanner, kw)
+
+ if not scanner:
+ continue
+
+ path = path_func(scanner)
+
+ 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 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.
+ scanner = root_node_scanner
+
+ return scanner
+
def get_env_scanner(self, env, kw={}):
return env.get_scanner(self.scanner_key())
diff --git a/src/engine/SCons/Scanner/SWIG.py b/src/engine/SCons/Scanner/SWIG.py
new file mode 100644
index 0000000..2650e4b
--- /dev/null
+++ b/src/engine/SCons/Scanner/SWIG.py
@@ -0,0 +1,45 @@
+"""SCons.Scanner.SWIG
+
+This module implements the dependency scanner for SWIG code.
+
+"""
+
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import SCons.Scanner
+
+SWIGSuffixes = [ '.i' ]
+
+def SWIGScanner():
+ expr = '^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)'
+ scanner = SCons.Scanner.ClassicCPP("SWIGScanner", ".i", "SWIGPATH", expr)
+ return scanner
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/src/engine/SCons/Tool/__init__.py b/src/engine/SCons/Tool/__init__.py
index 7374687..0594798 100644
--- a/src/engine/SCons/Tool/__init__.py
+++ b/src/engine/SCons/Tool/__init__.py
@@ -51,6 +51,7 @@ import SCons.Scanner.C
import SCons.Scanner.D
import SCons.Scanner.LaTeX
import SCons.Scanner.Prog
+import SCons.Scanner.SWIG
DefaultToolpath=[]
@@ -60,6 +61,7 @@ LaTeXScanner = SCons.Scanner.LaTeX.LaTeXScanner()
PDFLaTeXScanner = SCons.Scanner.LaTeX.PDFLaTeXScanner()
ProgramScanner = SCons.Scanner.Prog.ProgramScanner()
SourceFileScanner = SCons.Scanner.Base({}, name='SourceFileScanner')
+SWIGScanner = SCons.Scanner.SWIG.SWIGScanner()
CSuffixes = [".c", ".C", ".cxx", ".cpp", ".c++", ".cc",
".h", ".H", ".hxx", ".hpp", ".hh",
@@ -73,12 +75,17 @@ IDLSuffixes = [".idl", ".IDL"]
LaTeXSuffixes = [".tex", ".ltx", ".latex"]
+SWIGSuffixes = ['.i']
+
for suffix in CSuffixes:
SourceFileScanner.add_scanner(suffix, CScanner)
for suffix in DSuffixes:
SourceFileScanner.add_scanner(suffix, DScanner)
+for suffix in SWIGSuffixes:
+ SourceFileScanner.add_scanner(suffix, SWIGScanner)
+
# FIXME: what should be done here? Two scanners scan the same extensions,
# but look for different files, e.g., "picture.eps" vs. "picture.pdf".
# The builders for DVI and PDF explicitly reference their scanners
diff --git a/src/engine/SCons/Tool/install.py b/src/engine/SCons/Tool/install.py
index 9d5db9f..4226d56 100644
--- a/src/engine/SCons/Tool/install.py
+++ b/src/engine/SCons/Tool/install.py
@@ -374,6 +374,7 @@ def generate(env):
source_factory = env.fs.Entry,
multi = 1,
emitter = [ add_targets_to_INSTALLED_FILES, ],
+ source_scanner = SCons.Scanner.Base( {}, name = 'Install', recursive = False ),
name = 'InstallBuilder')
global BaseVersionedInstallBuilder
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py
index 44686ef..309585d 100644
--- a/src/engine/SCons/Tool/swig.py
+++ b/src/engine/SCons/Tool/swig.py
@@ -39,7 +39,6 @@ import subprocess
import SCons.Action
import SCons.Defaults
-import SCons.Scanner
import SCons.Tool
import SCons.Util
import SCons.Node
@@ -177,11 +176,6 @@ def generate(env):
env['_SWIGINCFLAGS'] = '$( ${_concat(SWIGINCPREFIX, SWIGPATH, SWIGINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
env['SWIGCOM'] = '$SWIG -o $TARGET ${_SWIGOUTDIR} ${_SWIGINCFLAGS} $SWIGFLAGS $SOURCES'
- expr = '^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)'
- scanner = SCons.Scanner.ClassicCPP("SWIGScan", ".i", "SWIGPATH", expr)
-
- env.Append(SCANNERS = scanner)
-
def exists(env):
swig = env.get('SWIG') or env.Detect(['swig'])
return swig