From: stevenknight Date: Wed, 14 Apr 2004 13:43:32 +0000 (+0000) Subject: Filter null values from the _concat() list. (Chad Austin) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e5d7003d92635686b5f91b4be2ef2d9db09bf89a;p=scons.git Filter null values from the _concat() list. (Chad Austin) git-svn-id: http://scons.tigris.org/svn/scons/trunk@955 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index bf2c7607..b5ed5001 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -22,6 +22,9 @@ RELEASE 0.96 - XXX - Allow the emitter argument to a Builder() to be or expand to a list of emitter functions, which will be called in sequence. + - Suppress null values in construction variables like $LIBS that use + the internal _concat() function. + From Chad Austin and Christoph Wiedemann: - Add support for a $RPATH variable to supply a list of directories diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index 94ab8d54..89ac0d36 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -173,20 +173,21 @@ def _concat(prefix, list, suffix, env, f=lambda x: x): for x in list: x = str(x) + if x: - if prefix: - if prefix[-1] == ' ': - ret.append(prefix[:-1]) - elif x[:len(prefix)] != prefix: - x = prefix + x + if prefix: + if prefix[-1] == ' ': + ret.append(prefix[:-1]) + elif x[:len(prefix)] != prefix: + x = prefix + x - ret.append(x) + ret.append(x) - if suffix: - if suffix[0] == ' ': - ret.append(suffix[1:]) - elif x[-len(suffix):] != suffix: - ret[-1] = ret[-1]+suffix + if suffix: + if suffix[0] == ' ': + ret.append(suffix[1:]) + elif x[-len(suffix):] != suffix: + ret[-1] = ret[-1]+suffix return ret diff --git a/test/LIBS.py b/test/LIBS.py index 645c625e..c91e38d1 100644 --- a/test/LIBS.py +++ b/test/LIBS.py @@ -42,6 +42,7 @@ foo1_exe = test.workpath('foo1' + _exe) foo2_exe = test.workpath('foo2' + _exe) foo3_exe = test.workpath('foo3' + _exe) foo4_exe = test.workpath('foo4' + _exe) +foo5_exe = test.workpath('foo5' + _exe) test.write('SConstruct', """ env = Environment(LIBS=['bar'], LIBPATH = '.') @@ -52,6 +53,8 @@ env3 = Environment(LIBS='bar', LIBPATH = '.') env3.Program(target='foo3', source='foo3.c') 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') SConscript('sub1/SConscript', 'env') SConscript('sub2/SConscript', 'env') """ % (bar_lib, bar_lib)) @@ -84,6 +87,7 @@ test.write('foo1.c', foo_contents) test.write('foo2.c', foo_contents) test.write('foo3.c', foo_contents) test.write('foo4.c', foo_contents) +test.write('foo5.c', foo_contents) test.write(['sub1', 'bar.c'], r""" #include @@ -112,12 +116,14 @@ void baz() } """) -test.run(arguments = '.') +# ar sometimes produces a "warning" on stderr -- ar: creating sub1/libbar.a +test.run(arguments = '.', stderr=None) test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c\n') 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.write('SConstruct', """