summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Scanner
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-09-18 13:46:51 (GMT)
committerSteven Knight <knight@baldmt.com>2004-09-18 13:46:51 (GMT)
commitdda1f7bcb8bac0d5dc29d0148f28805d5f205a8f (patch)
tree21e631d50c63a66d2c43813ee8c52990c47f96de /src/engine/SCons/Scanner
parent80a0699a0a8de7400e34c2e72dce9b9abebd674d (diff)
downloadSCons-dda1f7bcb8bac0d5dc29d0148f28805d5f205a8f.zip
SCons-dda1f7bcb8bac0d5dc29d0148f28805d5f205a8f.tar.gz
SCons-dda1f7bcb8bac0d5dc29d0148f28805d5f205a8f.tar.bz2
Don't put LIBS Nodes in the scanned results list multiple times.
Diffstat (limited to 'src/engine/SCons/Scanner')
-rw-r--r--src/engine/SCons/Scanner/Prog.py36
-rw-r--r--src/engine/SCons/Scanner/ProgTests.py16
2 files changed, 37 insertions, 15 deletions
diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py
index 3c45ca2..6efb44a 100644
--- a/src/engine/SCons/Scanner/Prog.py
+++ b/src/engine/SCons/Scanner/Prog.py
@@ -30,11 +30,11 @@ import SCons.Node.FS
import SCons.Scanner
import SCons.Util
-def ProgScan(fs = SCons.Node.FS.default_fs):
+def ProgScan(fs = SCons.Node.FS.default_fs, **kw):
"""Return a prototype Scanner instance for scanning executable
files for static-lib dependencies"""
- pf = SCons.Scanner.FindPathDirs('LIBPATH', fs)
- ps = SCons.Scanner.Base(scan, "ProgScan", path_function = pf)
+ kw['path_function'] = SCons.Scanner.FindPathDirs('LIBPATH', fs)
+ ps = apply(SCons.Scanner.Base, [scan, "ProgScan"], kw)
return ps
def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs):
@@ -69,18 +69,24 @@ def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs):
except KeyError:
suffix = [ '' ]
- find_file = SCons.Node.FS.find_file
- adjustixes = SCons.Util.adjustixes
- result = []
+ pairs = []
for suf in map(env.subst, suffix):
for pref in map(env.subst, prefix):
- for lib in libs:
- if SCons.Util.is_String(lib):
- lib = env.subst(lib)
- lib = adjustixes(lib, pref, suf)
- lib = find_file(lib, libpath, fs.File)
- if lib:
- result.append(lib)
- else:
- result.append(lib)
+ pairs.append((pref, suf))
+
+ result = []
+
+ find_file = SCons.Node.FS.find_file
+ 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, fs.File)
+ if l:
+ result.append(l)
+ else:
+ result.append(lib)
+
return result
diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py
index f3a2755..1100f34 100644
--- a/src/engine/SCons/Scanner/ProgTests.py
+++ b/src/engine/SCons/Scanner/ProgTests.py
@@ -185,6 +185,21 @@ class ProgScanTestCase7(unittest.TestCase):
deps = s('dummy', env, path)
assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
+class ProgScanTestCase8(unittest.TestCase):
+ def runTest(self):
+
+ class DummyNode:
+ pass
+ n = DummyNode()
+ env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
+ LIBS=[n],
+ LIBPREFIXES=['p1-', 'p2-'],
+ LIBSUFFIXES=['.1', '2'])
+ s = SCons.Scanner.Prog.ProgScan(node_class = DummyNode)
+ path = s.path(env)
+ deps = s('dummy', env, path)
+ assert deps == [n], deps
+
def suite():
suite = unittest.TestSuite()
suite.addTest(ProgScanTestCase1())
@@ -193,6 +208,7 @@ def suite():
suite.addTest(ProgScanTestCase5())
suite.addTest(ProgScanTestCase6())
suite.addTest(ProgScanTestCase7())
+ suite.addTest(ProgScanTestCase8())
if hasattr(types, 'UnicodeType'):
code = """if 1:
class ProgScanTestCase4(unittest.TestCase):