summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorAlexey Klimkin <klimkin@gmail.com>2015-01-14 01:40:33 (GMT)
committerAlexey Klimkin <klimkin@gmail.com>2015-01-14 01:40:33 (GMT)
commit505226b97a4aaf41695e3e1c818f768e35565bf9 (patch)
tree3a0807cb41eb3fa091e3e83e127a73a4db7fc739 /src/engine
parent2d33788ee03708960bee8899129c244d957ee2be (diff)
downloadSCons-505226b97a4aaf41695e3e1c818f768e35565bf9.zip
SCons-505226b97a4aaf41695e3e1c818f768e35565bf9.tar.gz
SCons-505226b97a4aaf41695e3e1c818f768e35565bf9.tar.bz2
Fix incomplete LIBS flattening and substitution in Program scanner
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Scanner/Prog.py14
-rw-r--r--src/engine/SCons/Scanner/ProgTests.py28
2 files changed, 39 insertions, 3 deletions
diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py
index 49e93a5..848f874 100644
--- a/src/engine/SCons/Scanner/Prog.py
+++ b/src/engine/SCons/Scanner/Prog.py
@@ -38,6 +38,15 @@ def ProgramScanner(**kw):
ps = SCons.Scanner.Base(scan, "ProgramScanner", **kw)
return ps
+def _split_libs(env, libs):
+ """
+ Substitute environment variables and split into list.
+ """
+ libs = env.subst(libs)
+ if SCons.Util.is_String(libs):
+ libs = libs.split()
+ return libs
+
def scan(node, env, libpath = ()):
"""
This scanner scans program files for static-library
@@ -51,9 +60,11 @@ def scan(node, env, libpath = ()):
# There are no LIBS in this environment, so just return a null list:
return []
if SCons.Util.is_String(libs):
- libs = libs.split()
+ libs = _split_libs(env, libs)
else:
libs = SCons.Util.flatten(libs)
+ libs = map(lambda x: _split_libs(env, x) if SCons.Util.is_String(x) else x, libs)
+ libs = SCons.Util.flatten(libs)
try:
prefix = env['LIBPREFIXES']
@@ -83,7 +94,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..98e20cc 100644
--- a/src/engine/SCons/Scanner/ProgTests.py
+++ b/src/engine/SCons/Scanner/ProgTests.py
@@ -73,7 +73,7 @@ class DummyEnvironment(object):
def subst(self, s, target=None, source=None, conv=None):
try:
- if s[0] == '$':
+ if isinstance(s, str) and s[0] == '$':
return self._dict[s[1:]]
except IndexError:
return ''
@@ -223,6 +223,30 @@ 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 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 +256,8 @@ def suite():
suite.addTest(ProgramScannerTestCase6())
suite.addTest(ProgramScannerTestCase7())
suite.addTest(ProgramScannerTestCase8())
+ suite.addTest(ProgramScannerTestCase9())
+ suite.addTest(ProgramScannerTestCase10())
try: unicode
except NameError: pass
else: