From 5b1a500609da93509d22d958c5839f47a86c7d7b Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 18 Sep 2004 13:46:51 +0000 Subject: [PATCH] Don't put LIBS Nodes in the scanned results list multiple times. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1082 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Scanner/Prog.py | 36 ++++++++++++++++----------- src/engine/SCons/Scanner/ProgTests.py | 16 ++++++++++++ 2 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 3c45ca28..6efb44ac 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 f3a27551..1100f349 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): -- 2.26.2