From 6ae43fca86af61b8a871b220a37022c8ade44655 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 8 Mar 2002 18:22:23 +0000 Subject: [PATCH] Fix an exception caused by a null-string CPPPATH. git-svn-id: http://scons.tigris.org/svn/scons/trunk@288 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 +++ src/engine/SCons/Util.py | 25 ++++++++++++++++--------- src/engine/SCons/UtilTests.py | 6 ++++++ test/CPPPATH.py | 8 ++++++++ test/LIBPATH.py | 8 ++++++++ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index cc047da0..fff6014e 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -32,6 +32,9 @@ RELEASE 0.06 - - Use the POSIX-standard lex -t flag, not the GNU-specific -o flag. (Bug reported by Russell Christensen.) + - Fixed an exception when CPPPATH or LIBPATH is a null string. + (Bug reported by Richard Kiss.) + RELEASE 0.05 - Thu, 21 Feb 2002 16:50:03 -0600 diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 038468f5..2202abd1 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -306,7 +306,12 @@ class VarInterpolator: if not dict.has_key(self.src): dict[self.dest] = '' return - src = self.prepareSrc(dict) + + src = filter(lambda x: not x is None, self.prepareSrc(dict)) + + if not src: + dict[self.dest] = '' + return try: prefix = str(dict[self.prefix]) @@ -345,16 +350,18 @@ class DirVarInterp(VarInterpolator): self.fs = None self.Dir = None self.dictInstCache = {} - + def prepareSrc(self, dict): src = VarInterpolator.prepareSrc(self, dict) - - def prepare(x, self=self): - if not isinstance(x, SCons.Node.Node): - return self.fs.Dir(str(x), directory=self.dir) - else: - return x - + + def prepare(x, self=self): + if isinstance(x, SCons.Node.Node): + return x + elif str(x): + return self.fs.Dir(str(x), directory=self.dir) + else: + return None + return map(prepare, src) def instance(self, dir, fs): diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 0e9f7b5f..bcb93d09 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -242,6 +242,12 @@ class UtilTestCase(unittest.TestCase): assert dict['_INCFLAGS'][7] == '$)', \ dict['_INCFLAGS'][7] + dict = {'CPPPATH' : '', + 'LIBPATH' : '' } + autogenerate(dict, dir = SCons.Node.FS.default_fs.Dir('/yy')) + assert len(dict['_INCFLAGS']) == 0, dict['_INCFLAGS'] + assert len(dict['_LIBDIRFLAGS']) == 0, dict['_LIBDIRFLAGS'] + def test_render_tree(self): class Node: def __init__(self, name, children=[]): diff --git a/test/CPPPATH.py b/test/CPPPATH.py index 98fabe62..372f6b61 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -176,4 +176,12 @@ SConscript('variant/SConscript', "env") test.up_to_date(arguments = args) +# Check that a null-string CPPPATH doesn't blow up. +test.write('SConstruct', """ +env = Environment(CPPPATH = '') +env.Library('foo', source = '') +""") + +test.run(arguments = '.') + test.pass_test() diff --git a/test/LIBPATH.py b/test/LIBPATH.py index 710ee546..b2ead7a2 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -112,4 +112,12 @@ env.Library(target = './libs/foo1', source = 'f1.c') test.up_to_date(arguments = '.', stderr = None) +# Check that a null-string LIBPATH doesn't blow up. +test.write('SConstruct', """ +env = Environment(LIBPATH = '') +env.Library('foo', source = '') +""") + +test.run(arguments = '.') + test.pass_test() -- 2.26.2