Don't put LIBS Nodes in the scanned results list multiple times.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 18 Sep 2004 13:46:51 +0000 (13:46 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 18 Sep 2004 13:46:51 +0000 (13:46 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1082 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Scanner/Prog.py
src/engine/SCons/Scanner/ProgTests.py

index 3c45ca28487cdf32acf64a5ae2c826461eedaa41..6efb44ac70b44d0220c14dfc825391b5684d5867 100644 (file)
@@ -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
index f3a275517e7dcb7ddbb065a8c1a831ce8a0f2437..1100f34939ec4878654e5a133f0890f0fbf227ee 100644 (file)
@@ -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):