summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Scanner
diff options
context:
space:
mode:
authorRussel Winder <russel@winder.org.uk>2015-12-24 16:32:14 (GMT)
committerRussel Winder <russel@winder.org.uk>2015-12-24 16:32:14 (GMT)
commit2a270c8f314e959c78e9deda29c8f250bb934dd6 (patch)
tree7008e644357036404f0861c8ba1bbbf43b2b4123 /src/engine/SCons/Scanner
parenta7d764ed831fa3243aa0bd3307f641e1e1f9f8a8 (diff)
parent9d558dd65deacc958edc1f0da2dab1ec56ff4e4e (diff)
downloadSCons-2a270c8f314e959c78e9deda29c8f250bb934dd6.zip
SCons-2a270c8f314e959c78e9deda29c8f250bb934dd6.tar.gz
SCons-2a270c8f314e959c78e9deda29c8f250bb934dd6.tar.bz2
Post merge commit for safety. Building Fortran code works, but tests fail.
Diffstat (limited to 'src/engine/SCons/Scanner')
-rw-r--r--src/engine/SCons/Scanner/C.py2
-rw-r--r--src/engine/SCons/Scanner/CTests.py13
-rw-r--r--src/engine/SCons/Scanner/Dir.py2
-rw-r--r--src/engine/SCons/Scanner/FortranTests.py13
-rw-r--r--src/engine/SCons/Scanner/IDL.py2
-rw-r--r--src/engine/SCons/Scanner/IDLTests.py13
-rw-r--r--src/engine/SCons/Scanner/Prog.py25
-rw-r--r--src/engine/SCons/Scanner/ProgTests.py35
-rw-r--r--src/engine/SCons/Scanner/RC.py2
-rw-r--r--src/engine/SCons/Scanner/SWIG.py45
10 files changed, 119 insertions, 33 deletions
diff --git a/src/engine/SCons/Scanner/C.py b/src/engine/SCons/Scanner/C.py
index 74b01a4..3b34b88 100644
--- a/src/engine/SCons/Scanner/C.py
+++ b/src/engine/SCons/Scanner/C.py
@@ -1,6 +1,6 @@
"""SCons.Scanner.C
-This module implements the depenency scanner for C/C++ code.
+This module implements the dependency scanner for C/C++ code.
"""
diff --git a/src/engine/SCons/Scanner/CTests.py b/src/engine/SCons/Scanner/CTests.py
index 6418754..9c7df12 100644
--- a/src/engine/SCons/Scanner/CTests.py
+++ b/src/engine/SCons/Scanner/CTests.py
@@ -270,17 +270,18 @@ class CScannerTestCase5(unittest.TestCase):
path = s.path(env)
n = env.File('f3.cpp')
- def my_rexists(s=n):
- s.rexists_called = 1
- return s.old_rexists()
- setattr(n, 'old_rexists', n.rexists)
- setattr(n, 'rexists', my_rexists)
+ def my_rexists(s):
+ s.Tag('rexists_called', 1)
+ return SCons.Node._rexists_map[s.GetTag('old_rexists')](s)
+ n.Tag('old_rexists', n._func_rexists)
+ SCons.Node._rexists_map[3] = my_rexists
+ n._func_rexists = 3
deps = s(n, env, path)
# Make sure rexists() got called on the file node being
# scanned, essential for cooperation with VariantDir functionality.
- assert n.rexists_called
+ assert n.GetTag('rexists_called')
headers = ['f1.h', 'f2.h', 'f3-test.h',
'd1/f1.h', 'd1/f2.h', 'd1/f3-test.h']
diff --git a/src/engine/SCons/Scanner/Dir.py b/src/engine/SCons/Scanner/Dir.py
index 1cecfb7..cbfb6fb 100644
--- a/src/engine/SCons/Scanner/Dir.py
+++ b/src/engine/SCons/Scanner/Dir.py
@@ -77,7 +77,7 @@ def scan_on_disk(node, env, path=()):
that and then call the in-memory scanning function.
"""
try:
- flist = node.fs.listdir(node.abspath)
+ flist = node.fs.listdir(node.get_abspath())
except (IOError, OSError):
return []
e = node.Entry
diff --git a/src/engine/SCons/Scanner/FortranTests.py b/src/engine/SCons/Scanner/FortranTests.py
index 252da64..aaefa79 100644
--- a/src/engine/SCons/Scanner/FortranTests.py
+++ b/src/engine/SCons/Scanner/FortranTests.py
@@ -356,17 +356,18 @@ class FortranScannerTestCase9(unittest.TestCase):
path = s.path(env)
n = env.File('fff3.f')
- def my_rexists(s=n):
- s.rexists_called = 1
- return s.old_rexists()
- setattr(n, 'old_rexists', n.rexists)
- setattr(n, 'rexists', my_rexists)
+ def my_rexists(s):
+ s.Tag('rexists_called', 1)
+ return SCons.Node._rexists_map[s.GetTag('old_rexists')](s)
+ n.Tag('old_rexists', n._func_rexists)
+ SCons.Node._rexists_map[3] = my_rexists
+ n._func_rexists = 3
deps = s(n, env, path)
# Make sure rexists() got called on the file node being
# scanned, essential for cooperation with VariantDir functionality.
- assert n.rexists_called
+ assert n.GetTag('rexists_called')
headers = ['d1/f3.f', 'f3.f']
deps_match(self, deps, headers)
diff --git a/src/engine/SCons/Scanner/IDL.py b/src/engine/SCons/Scanner/IDL.py
index 18084e8..86ee006 100644
--- a/src/engine/SCons/Scanner/IDL.py
+++ b/src/engine/SCons/Scanner/IDL.py
@@ -1,6 +1,6 @@
"""SCons.Scanner.IDL
-This module implements the depenency scanner for IDL (Interface
+This module implements the dependency scanner for IDL (Interface
Definition Language) files.
"""
diff --git a/src/engine/SCons/Scanner/IDLTests.py b/src/engine/SCons/Scanner/IDLTests.py
index 675c70c..227799e 100644
--- a/src/engine/SCons/Scanner/IDLTests.py
+++ b/src/engine/SCons/Scanner/IDLTests.py
@@ -290,17 +290,18 @@ class IDLScannerTestCase5(unittest.TestCase):
path = s.path(env)
n = env.File('t3.idl')
- def my_rexists(s=n):
- s.rexists_called = 1
- return s.old_rexists()
- setattr(n, 'old_rexists', n.rexists)
- setattr(n, 'rexists', my_rexists)
+ def my_rexists(s):
+ s.Tag('rexists_called', 1)
+ return SCons.Node._rexists_map[s.GetTag('old_rexists')](s)
+ n.Tag('old_rexists', n._func_rexists)
+ SCons.Node._rexists_map[3] = my_rexists
+ n._func_rexists = 3
deps = s(n, env, path)
# Make sure rexists() got called on the file node being
# scanned, essential for cooperation with VariantDir functionality.
- assert n.rexists_called
+ assert n.GetTag('rexists_called')
headers = ['d1/f1.idl', 'd1/f2.idl',
'f1.idl', 'f2.idl', 'f3-test.idl',
diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py
index 49e93a5..6567b3d 100644
--- a/src/engine/SCons/Scanner/Prog.py
+++ b/src/engine/SCons/Scanner/Prog.py
@@ -38,6 +38,24 @@ def ProgramScanner(**kw):
ps = SCons.Scanner.Base(scan, "ProgramScanner", **kw)
return ps
+def _subst_libs(env, libs):
+ """
+ Substitute environment variables and split into list.
+ """
+ if SCons.Util.is_String(libs):
+ libs = env.subst(libs)
+ if SCons.Util.is_String(libs):
+ libs = libs.split()
+ elif SCons.Util.is_Sequence(libs):
+ _libs = []
+ for l in libs:
+ _libs += _subst_libs(env, l)
+ libs = _libs
+ else:
+ # libs is an object (Node, for example)
+ libs = [libs]
+ return libs
+
def scan(node, env, libpath = ()):
"""
This scanner scans program files for static-library
@@ -50,10 +68,8 @@ def scan(node, env, libpath = ()):
except KeyError:
# There are no LIBS in this environment, so just return a null list:
return []
- if SCons.Util.is_String(libs):
- libs = libs.split()
- else:
- libs = SCons.Util.flatten(libs)
+
+ libs = _subst_libs(env, libs)
try:
prefix = env['LIBPREFIXES']
@@ -83,7 +99,6 @@ def scan(node, env, libpath = ()):
adjustixes = SCons.Util.adjustixes
for lib in libs:
if SCons.Util.is_String(lib):
- lib = env.subst(lib)
for pref, suf in pairs:
l = adjustixes(lib, pref, suf)
l = find_file(l, libpath, verbose=print_find_libs)
diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py
index a5c8956..e7c791c 100644
--- a/src/engine/SCons/Scanner/ProgTests.py
+++ b/src/engine/SCons/Scanner/ProgTests.py
@@ -32,6 +32,7 @@ import TestUnit
import SCons.Node.FS
import SCons.Scanner.Prog
+import SCons.Subst
test = TestCmd.TestCmd(workdir = '')
@@ -72,12 +73,7 @@ class DummyEnvironment(object):
del self.Dictionary()[key]
def subst(self, s, target=None, source=None, conv=None):
- try:
- if s[0] == '$':
- return self._dict[s[1:]]
- except IndexError:
- return ''
- return s
+ return SCons.Subst.scons_subst(s, self, gvars=self._dict, lvars=self._dict)
def subst_path(self, path, target=None, source=None, conv=None):
if not isinstance(path, list):
@@ -223,6 +219,31 @@ class ProgramScannerTestCase8(unittest.TestCase):
deps = s(DummyNode('dummy'), env, path)
assert deps == [n1, n2], deps
+class ProgramScannerTestCase9(unittest.TestCase):
+ def runTest(self):
+ env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
+ LIBS=['foo', '$LIBBAR'],
+ LIBPREFIXES=['lib'],
+ LIBSUFFIXES=['.a'],
+ LIBBAR=['sub/libbar', 'xyz.other'])
+ s = SCons.Scanner.Prog.ProgramScanner()
+ path = s.path(env)
+ deps = s(DummyNode('dummy'), env, path)
+ assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), list(map(str, deps))
+
+class ProgramScannerTestCase10(unittest.TestCase):
+ def runTest(self):
+ env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
+ LIBS=['foo', '$LIBBAR'],
+ LIBPREFIXES=['lib'],
+ LIBSUFFIXES=['.a'],
+ LIBBAR='sub/libbar $LIBBAR2',
+ LIBBAR2=['xyz.other'])
+ s = SCons.Scanner.Prog.ProgramScanner()
+ path = s.path(env)
+ deps = s(DummyNode('dummy'), env, path)
+ assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), list(map(str, deps))
+
def suite():
suite = unittest.TestSuite()
suite.addTest(ProgramScannerTestCase1())
@@ -232,6 +253,8 @@ def suite():
suite.addTest(ProgramScannerTestCase6())
suite.addTest(ProgramScannerTestCase7())
suite.addTest(ProgramScannerTestCase8())
+ suite.addTest(ProgramScannerTestCase9())
+ suite.addTest(ProgramScannerTestCase10())
try: unicode
except NameError: pass
else:
diff --git a/src/engine/SCons/Scanner/RC.py b/src/engine/SCons/Scanner/RC.py
index 437b861..61393ae 100644
--- a/src/engine/SCons/Scanner/RC.py
+++ b/src/engine/SCons/Scanner/RC.py
@@ -1,6 +1,6 @@
"""SCons.Scanner.RC
-This module implements the depenency scanner for RC (Interface
+This module implements the dependency scanner for RC (Interface
Definition Language) files.
"""
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: