From: stevenknight Date: Sat, 18 Sep 2004 15:24:28 +0000 (+0000) Subject: Allow LIBS to contain lists of lists. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=064b3ea52e2289c80990696758cbd7a2c166f958;p=scons.git Allow LIBS to contain lists of lists. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1083 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 6ebc6ebb..381b0ae7 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -232,6 +232,8 @@ def _concat(prefix, list, suffix, env, f=lambda x: x): if not list: return list + if SCons.Util.is_List(list): + list = SCons.Util.flatten(list) list = f(env.subst_path(list)) result = [] diff --git a/src/engine/SCons/Scanner/Prog.py b/src/engine/SCons/Scanner/Prog.py index 6efb44ac..78b72330 100644 --- a/src/engine/SCons/Scanner/Prog.py +++ b/src/engine/SCons/Scanner/Prog.py @@ -52,7 +52,9 @@ def scan(node, env, libpath = (), fs = SCons.Node.FS.default_fs): return [] if SCons.Util.is_String(libs): libs = string.split(libs) - elif not SCons.Util.is_List(libs): + elif SCons.Util.is_List(libs): + libs = SCons.Util.flatten(libs) + else: libs = [libs] try: diff --git a/src/engine/SCons/Scanner/ProgTests.py b/src/engine/SCons/Scanner/ProgTests.py index 1100f349..f7064ffc 100644 --- a/src/engine/SCons/Scanner/ProgTests.py +++ b/src/engine/SCons/Scanner/ProgTests.py @@ -190,15 +190,26 @@ class ProgScanTestCase8(unittest.TestCase): class DummyNode: pass - n = DummyNode() + + n1 = DummyNode() + env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ], + LIBS=[n1], + 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 == [n1], deps + + n2 = DummyNode() env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ], - LIBS=[n], + LIBS=[n1, [n2]], 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 + assert deps == [n1, n2], deps def suite(): suite = unittest.TestSuite() diff --git a/test/LIBS.py b/test/LIBS.py index cc31cad1..3ff26e0d 100644 --- a/test/LIBS.py +++ b/test/LIBS.py @@ -43,6 +43,7 @@ foo2_exe = test.workpath('foo2' + _exe) foo3_exe = test.workpath('foo3' + _exe) foo4_exe = test.workpath('foo4' + _exe) foo5_exe = test.workpath('foo5' + _exe) +slprog_exe = test.workpath('slprog' + _exe) test.write('SConstruct', """ env = Environment(LIBS=['bar'], LIBPATH = '.') @@ -55,6 +56,8 @@ env4 = Environment(LIBS=File(r'%s'), LIBPATH = '.') env4.Program(target='foo4', source='foo4.c') env5 = Environment(LIBS=['bar', '$UNSPECIFIED'], LIBPATH = '.') env5.Program(target='foo5', source='foo5.c') +sl = env.StaticLibrary('sl.c') +env.Program(target='slprog.c', LIBS=[sl]) SConscript('sub1/SConscript', 'env') SConscript('sub2/SConscript', 'env') """ % (bar_lib, bar_lib)) @@ -89,6 +92,24 @@ test.write('foo3.c', foo_contents) test.write('foo4.c', foo_contents) test.write('foo5.c', foo_contents) +test.write('sl.c', """\ +void +sl(void) +{ + printf("sl.c\\n"); +} +""") + +test.write('slprog.c', """\ +int +main(int argc, char *argv[]) +{ + sl(); + printf("slprog.c\\n"); + exit (0); +} +""") + test.write(['sub1', 'bar.c'], r""" #include @@ -124,6 +145,7 @@ test.run(program=foo2_exe, stdout='sub1/bar.c\nsub1/baz.c\n') test.run(program=foo3_exe, stdout='sub1/bar.c\nsub1/baz.c\n') test.run(program=foo4_exe, stdout='sub1/bar.c\nsub1/baz.c\n') test.run(program=foo5_exe, stdout='sub1/bar.c\nsub1/baz.c\n') +test.run(program=slprog_exe, stdout='sl.c\nslprog.c\n') # test.write('SConstruct', """