diff options
author | dirkbaechle <dl9obn@darc.de> | 2015-02-02 17:23:09 (GMT) |
---|---|---|
committer | dirkbaechle <dl9obn@darc.de> | 2015-02-02 17:23:09 (GMT) |
commit | b22e9980df40305bb8beac3ea03bb045e01a031c (patch) | |
tree | 84fd5ee0398f814be2e4852ac526ed80e8ac3e5a | |
parent | 7633be5b72a7070f8bb014324be653c1156a854c (diff) | |
parent | 3c229dfb912628cede20119af721862d87202c0b (diff) | |
download | SCons-b22e9980df40305bb8beac3ea03bb045e01a031c.zip SCons-b22e9980df40305bb8beac3ea03bb045e01a031c.tar.gz SCons-b22e9980df40305bb8beac3ea03bb045e01a031c.tar.bz2 |
Merged in klimkin/scons (pull request #205)
Fix incomplete LIBS flattening and substitution in Program scanner
-rw-r--r-- | src/engine/SCons/Scanner/Prog.py | 25 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/ProgTests.py | 35 |
2 files changed, 49 insertions, 11 deletions
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 144addb..ace3ff4 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: |