summaryrefslogtreecommitdiffstats
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
parentc2d974ea65afe9ab1968a16c797155fd799527ca (diff)
parent04b306103a2c37b90f2d764112c0cb5527313849 (diff)
downloadSCons-4a0683af8a414b8143dbc369d59f4349d99089ac.zip
SCons-4a0683af8a414b8143dbc369d59f4349d99089ac.tar.gz
SCons-4a0683af8a414b8143dbc369d59f4349d99089ac.tar.bz2
Merged in williamblevins/scons_20150323 (pull request #244)
-rw-r--r--QMTest/TestCommon.py32
-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
-rw-r--r--test/Fortran/FORTRANSUFFIXES.py56
-rw-r--r--test/IDL/IDLSUFFIXES.py5
-rw-r--r--test/QT/manual.py6
-rw-r--r--test/SWIG/recursive-includes-cpp.py123
-rw-r--r--test/Scanner/CrossLanguageNoExtension.py110
-rw-r--r--test/Scanner/generated.py1
-rw-r--r--test/explain/basic.py25
-rw-r--r--test/explain/save-info.py7
19 files changed, 433 insertions, 118 deletions
diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py
index 4e90e16..c4a5373 100644
--- a/QMTest/TestCommon.py
+++ b/QMTest/TestCommon.py
@@ -36,6 +36,8 @@ provided by the TestCommon class:
test.must_contain('file', 'required text\n')
+ test.must_contain_all(output, input, ['title', find])
+
test.must_contain_all_lines(output, lines, ['title', find])
test.must_contain_any_line(output, lines, ['title', find])
@@ -305,6 +307,36 @@ class TestCommon(TestCmd):
print file_contents
self.fail_test(not contains)
+ def must_contain_all(self, output, input, title=None, find=None):
+ """Ensures that the specified output string (first argument)
+ contains all of the specified input as a block (second argument).
+
+ An optional third argument can be used to describe the type
+ of output being searched, and only shows up in failure output.
+
+ An optional fourth argument can be used to supply a different
+ function, of the form "find(line, output), to use when searching
+ for lines in the output.
+ """
+ if find is None:
+ def find(o, i):
+ try:
+ return o.index(i)
+ except ValueError:
+ return None
+
+ if is_List(output):
+ output = os.newline.join(output)
+
+ if find(output, input) is None:
+ if title is None:
+ title = 'output'
+ print 'Missing expected input from %s:' % title
+ print input
+ print self.banner(title + ' ')
+ print output
+ self.fail_test()
+
def must_contain_all_lines(self, output, lines, title=None, find=None):
"""Ensures that the specified output string (first argument)
contains all of the specified lines (second argument).
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
diff --git a/test/Fortran/FORTRANSUFFIXES.py b/test/Fortran/FORTRANSUFFIXES.py
index 583b71b..9673e6f 100644
--- a/test/Fortran/FORTRANSUFFIXES.py
+++ b/test/Fortran/FORTRANSUFFIXES.py
@@ -56,51 +56,51 @@ env = Environment(FORTRANPATH = ['.'],
env.Append(FORTRANSUFFIXES = ['.x'])
env.Object(target = 'test1', source = 'test1.f')
env.InstallAs('test1_f', 'test1.f')
-env.InstallAs('test1_h', 'test1.h')
env.InstallAs('test1_x', 'test1.x')
+env.InstallAs('test2_f', 'test2.f')
""" % locals())
test.write('test1.f', """\
test1.f 1
- INCLUDE 'test1.h'
+ INCLUDE 'test2.f'
INCLUDE 'test1.x'
""")
-test.write('test1.h', """\
- test1.h 1
- INCLUDE 'foo.h'
+test.write('test2.f', """\
+ test2.f 1
+ INCLUDE 'foo.f'
""")
test.write('test1.x', """\
test1.x 1
- INCLUDE 'foo.h'
+ INCLUDE 'foo.f'
""")
-test.write('foo.h', """\
- foo.h 1
+test.write('foo.f', """\
+ foo.f 1
""")
expect = test.wrap_stdout("""\
%(_python_)s myfc.py test1.o test1.f
Install file: "test1.f" as "test1_f"
-Install file: "test1.h" as "test1_h"
Install file: "test1.x" as "test1_x"
+Install file: "test2.f" as "test2_f"
""" % locals())
test.run(arguments='.', stdout=expect)
test.must_match('test1.o', """\
test1.f 1
- test1.h 1
- foo.h 1
+ test2.f 1
+ foo.f 1
test1.x 1
- foo.h 1
+ foo.f 1
""")
test.up_to_date(arguments='.')
-test.write('foo.h', """\
- foo.h 2
+test.write('foo.f', """\
+ foo.f 2
""")
expect = test.wrap_stdout("""\
@@ -111,17 +111,17 @@ test.run(arguments='.', stdout=expect)
test.must_match('test1.o', """\
test1.f 1
- test1.h 1
- foo.h 2
+ test2.f 1
+ foo.f 2
test1.x 1
- foo.h 2
+ foo.f 2
""")
test.up_to_date(arguments='.')
test.write('test1.x', """\
test1.x 2
- INCLUDE 'foo.h'
+ INCLUDE 'foo.f'
""")
expect = test.wrap_stdout("""\
@@ -133,32 +133,32 @@ test.run(arguments='.', stdout=expect)
test.must_match('test1.o', """\
test1.f 1
- test1.h 1
- foo.h 2
+ test2.f 1
+ foo.f 2
test1.x 2
- foo.h 2
+ foo.f 2
""")
test.up_to_date(arguments='.')
-test.write('test1.h', """\
- test1.h 2
- INCLUDE 'foo.h'
+test.write('test2.f', """\
+ test2.f 2
+ INCLUDE 'foo.f'
""")
expect = test.wrap_stdout("""\
%(_python_)s myfc.py test1.o test1.f
-Install file: "test1.h" as "test1_h"
+Install file: "test2.f" as "test2_f"
""" % locals())
test.run(arguments='.', stdout=expect)
test.must_match('test1.o', """\
test1.f 1
- test1.h 2
- foo.h 2
+ test2.f 2
+ foo.f 2
test1.x 2
- foo.h 2
+ foo.f 2
""")
test.up_to_date(arguments='.')
diff --git a/test/IDL/IDLSUFFIXES.py b/test/IDL/IDLSUFFIXES.py
index f71ceba..0a9a50c 100644
--- a/test/IDL/IDLSUFFIXES.py
+++ b/test/IDL/IDLSUFFIXES.py
@@ -60,11 +60,6 @@ test.up_to_date(arguments='.')
test.write('foo.h', "foo.h 2\n")
-test.run(arguments='.', stdout=test.wrap_stdout("""\
-Install file: "foo.idl" as "foo_idl"
-Install file: "foo.x" as "foo_x"
-"""))
-
test.up_to_date(arguments='.')
test.pass_test()
diff --git a/test/QT/manual.py b/test/QT/manual.py
index ff38f32..d911fb3 100644
--- a/test/QT/manual.py
+++ b/test/QT/manual.py
@@ -46,13 +46,15 @@ sources = ['aaa.cpp', 'bbb.cpp', 'ddd.cpp', 'eee.cpp', 'main.cpp']
# normal invocation
sources.append(env.Moc('include/aaa.h'))
-env.Moc('bbb.cpp')
+moc = env.Moc('bbb.cpp')
+env.Ignore( moc, moc )
sources.extend(env.Uic('ui/ccc.ui')[1:])
# manual target specification
sources.append(env.Moc('moc-ddd.cpp', 'include/ddd.h',
QT_MOCHPREFIX='')) # Watch out !
-env.Moc('moc_eee.cpp', 'eee.cpp')
+moc = env.Moc('moc_eee.cpp', 'eee.cpp')
+env.Ignore( moc, moc )
sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'],
'ui/fff.ui')[1:])
diff --git a/test/SWIG/recursive-includes-cpp.py b/test/SWIG/recursive-includes-cpp.py
new file mode 100644
index 0000000..364bd73
--- /dev/null
+++ b/test/SWIG/recursive-includes-cpp.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python
+#
+# __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__"
+
+"""
+Verify that SWIG include directives produce the correct dependencies
+in cases of recursive inclusion.
+"""
+
+import os
+import TestSCons
+from SCons.Defaults import DefaultEnvironment
+
+DefaultEnvironment( tools = [ 'swig' ] )
+
+test = TestSCons.TestSCons()
+
+# Check for prerequisites of this test.
+for pre_req in ['swig', 'python']:
+ if not test.where_is(pre_req):
+ test.skip_test('Can not find installed "' + pre_req + '", skipping test.%s' % os.linesep)
+
+test.write("recursive.h", """\
+/* An empty header file. */
+""")
+
+test.write("main.h", """\
+#include "recursive.h"
+""")
+
+test.write("main.c", """\
+#include "main.h"
+""")
+
+test.write("mod.i", """\
+%module mod
+
+%include "main.h"
+
+#include "main.h"
+""")
+
+test.write('SConstruct', """\
+import distutils.sysconfig
+
+DefaultEnvironment( tools = [ 'swig' ] )
+
+env = Environment(
+ SWIGFLAGS = [
+ '-python'
+ ],
+ CPPPATH = [
+ distutils.sysconfig.get_python_inc()
+ ],
+ SHLIBPREFIX = ""
+)
+
+env.SharedLibrary(
+ 'mod.so',
+ [
+ "mod.i",
+ "main.c",
+ ]
+)
+""")
+
+expectMain = """\
++-main.os
+ +-main.c
+ +-main.h
+ +-recursive.h"""
+
+expectMod = """\
++-mod_wrap.os
+ +-mod_wrap.c
+ | +-mod.i
+ | +-main.h
+ | +-recursive.h"""
+
+# Validate that the recursive dependencies are found with SWIG scanning first.
+test.run( arguments = '--tree=all mod_wrap.os main.os' )
+
+test.must_contain_all( test.stdout(), expectMain )
+test.must_contain_all( test.stdout(), expectMod )
+
+# Validate that the recursive dependencies are found consistently.
+test.run( arguments = '--tree=all main.os mod_wrap.os' )
+
+test.must_contain_all( test.stdout(), expectMain )
+test.must_contain_all( test.stdout(), expectMod )
+
+test.run()
+test.up_to_date()
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/Scanner/CrossLanguageNoExtension.py b/test/Scanner/CrossLanguageNoExtension.py
new file mode 100644
index 0000000..5bf205f
--- /dev/null
+++ b/test/Scanner/CrossLanguageNoExtension.py
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+#
+# __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 TestSCons
+
+_python_ = TestSCons._python_
+
+test = TestSCons.TestSCons()
+
+# Test behavior of Scanners when evaluating implicit dependencies
+# for nodes that do not have mappings from their scanner_key
+# to a scanner instance
+
+test.write('SConstruct', """
+import re
+
+include_re = re.compile(r'^include\s+(\S+)$', re.M)
+
+def scan(node, env, scanpaths, arg):
+ contents = node.get_text_contents()
+ includes = include_re.findall(contents)
+ return includes
+
+def kfile_scan(node, env, scanpaths, arg):
+ print 'kscan: ' + str(node)
+ return scan(node, env, scanpaths, arg)
+
+def k2file_scan(node, env, scanpaths, arg):
+ print 'k2scan: ' + str(node)
+ return scan(node, env, scanpaths, arg)
+
+kscan = Scanner(name = 'kfile',
+ function = kfile_scan,
+ argument = None,
+ skeys = ['.k'],
+ recursive = True)
+
+k2scan = Scanner(name = 'k2',
+ function = k2file_scan,
+ argument = None,
+ skeys = ['.k2'])
+
+k2scan2 = Scanner(name = 'k2',
+ function = k2file_scan,
+ argument = None,
+ skeys = [''])
+
+env1 = Environment()
+env1.Append(SCANNERS = [ kscan, k2scan ] )
+env1.Command( 'k', 'foo.k', Copy( '$TARGET', '$SOURCE' ) )
+
+env2 = env1.Clone()
+env2.Append(SCANNERS = [ k2scan2 ] )
+env2.Command( 'k2', 'foo.k', Copy( '$TARGET', '$SOURCE' ) )
+""")
+
+test.write('foo.k',
+"""foo.k 1 line 1
+include xxx.k
+include yyy
+foo.k 1 line 4
+""")
+
+test.write('xxx.k', "xxx.k 1\n")
+test.write('yyy', "yyy 1\n")
+test.write('yyy.k2', "yyy.k2 1\n")
+
+expected_stdout = test.wrap_stdout("""\
+kscan: foo.k
+kscan: xxx.k
+kscan: yyy
+Copy("k", "foo.k")
+kscan: foo.k
+kscan: xxx.k
+k2scan: yyy
+Copy("k2", "foo.k")
+""")
+
+test.run(arguments='k k2', stdout=expected_stdout)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py
index 845111c..b41c7c8 100644
--- a/test/Scanner/generated.py
+++ b/test/Scanner/generated.py
@@ -338,6 +338,7 @@ class CScannerCounter(object):
import SCons.Tool
MyCScanner = CScannerCounter(SCons.Script.CScanner)
SCons.Tool.SourceFileScanner.add_scanner('.c', MyCScanner)
+SCons.Tool.SourceFileScanner.add_scanner('.h', MyCScanner)
env = Environment(CPPPATH = ".")
l = env.StaticLibrary("g", Split("libg_1.c libg_2.c libg_3.c"))
diff --git a/test/explain/basic.py b/test/explain/basic.py
index 5e31cfd..1072ac4 100644
--- a/test/explain/basic.py
+++ b/test/explain/basic.py
@@ -169,10 +169,18 @@ test.write(['src', 'file6.in'], "file6.in 1\n")
test.write(['src', 'subdir', 'file7.in'], "subdir/file7.in 1\n")
-args = '--debug=explain .'
+args = '--debug=explain ..'
expect = test.wrap_stdout("""\
+scons: building `%(inc_aaa)s' because it doesn't exist
+Install file: "aaa" as "%(inc_aaa)s"
+scons: building `%(inc_bbb_k)s' because it doesn't exist
+Install file: "bbb.k" as "%(inc_bbb_k)s"
+scons: building `%(inc_ddd)s' because it doesn't exist
+Install file: "ddd" as "%(inc_ddd)s"
+scons: building `%(inc_eee)s' because it doesn't exist
+Install file: "eee.in" as "%(inc_eee)s"
scons: building `file1' because it doesn't exist
%(_python_)s %(cat_py)s file1 file1.in
scons: building `file2' because it doesn't exist
@@ -181,14 +189,6 @@ scons: building `file3' because it doesn't exist
%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: building `file4' because it doesn't exist
%(_python_)s %(cat_py)s file4 - file4.in
-scons: building `%(inc_aaa)s' because it doesn't exist
-Install file: "aaa" as "%(inc_aaa)s"
-scons: building `%(inc_ddd)s' because it doesn't exist
-Install file: "ddd" as "%(inc_ddd)s"
-scons: building `%(inc_eee)s' because it doesn't exist
-Install file: "eee.in" as "%(inc_eee)s"
-scons: building `%(inc_bbb_k)s' because it doesn't exist
-Install file: "bbb.k" as "%(inc_bbb_k)s"
scons: building `file5' because it doesn't exist
%(_python_)s %(cat_py)s file5 file5.k
scons: building `file6' because it doesn't exist
@@ -236,6 +236,8 @@ test_value = '"second"'
WriteInitialTest( locals() )
expect = test.wrap_stdout("""\
+scons: rebuilding `%(inc_bbb_k)s' because `bbb.k' changed
+Install file: "bbb.k" as "%(inc_bbb_k)s"
scons: rebuilding `file1' because `file1.in' changed
%(_python_)s %(cat_py)s file1 file1.in
scons: rebuilding `file2' because `yyy' changed
@@ -244,11 +246,6 @@ scons: rebuilding `file3' because:
`yyy' changed
`zzz' changed
%(_python_)s %(cat_py)s file3 xxx yyy zzz
-scons: rebuilding `%(inc_bbb_k)s' because:
- `%(inc_ddd)s' is no longer a dependency
- `%(inc_eee)s' is no longer a dependency
- `bbb.k' changed
-Install file: "bbb.k" as "%(inc_bbb_k)s"
scons: rebuilding `file5' because `%(inc_bbb_k)s' changed
%(_python_)s %(cat_py)s file5 file5.k
scons: rebuilding `file6' because AlwaysBuild() is specified
diff --git a/test/explain/save-info.py b/test/explain/save-info.py
index d2ffc7d..af4c3f5 100644
--- a/test/explain/save-info.py
+++ b/test/explain/save-info.py
@@ -141,7 +141,7 @@ file5.k 1 line 4
test.write(['src', 'subdir', 'file6.in'], "subdir/file6.in 1\n")
#
-test.run(chdir='src', arguments='.')
+test.run(chdir='src', arguments='..')
test.must_match(['src', 'file1'], "file1.in 1\n")
test.must_match(['src', 'file2'], """\
@@ -176,10 +176,7 @@ scons: rebuilding `file3' because:
`yyy' changed
`zzz' changed
%(_python_)s %(cat_py)s file3 xxx yyy zzz
-scons: rebuilding `%(inc_bbb_k)s' because:
- `%(inc_ddd)s' is no longer a dependency
- `%(inc_eee)s' is no longer a dependency
- `bbb.k' changed
+scons: rebuilding `%(inc_bbb_k)s' because `bbb.k' changed
Install file: "bbb.k" as "%(inc_bbb_k)s"
scons: rebuilding `file5' because `%(inc_bbb_k)s' changed
%(_python_)s %(cat_py)s file5 file5.k