Fix an exception caused by a null-string CPPPATH.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 8 Mar 2002 18:22:23 +0000 (18:22 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 8 Mar 2002 18:22:23 +0000 (18:22 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@288 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Util.py
src/engine/SCons/UtilTests.py
test/CPPPATH.py
test/LIBPATH.py

index cc047da03757c248ab265fe8cb8e299813496f7e..fff6014e733ce5f5d1e1d87b691af3cc5789976c 100644 (file)
@@ -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
index 038468f5682b6e734077f0545754392abf1a492b..2202abd15e53b544545aa7c7ca69c2c8cec7a68d 100644 (file)
@@ -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):
index 0e9f7b5fac04540c0b1fcc2529e8ae047bd27ae0..bcb93d09044e07ec7f65fe9734c99753e025e2b6 100644 (file)
@@ -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=[]):
index 98fabe62a2cfd183218eec4228433a8a6e9f31fc..372f6b61390208e10f47011f1443ad2c7279d172 100644 (file)
@@ -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()
index 710ee5460e02c28bf79cf87692b67e462b2135d9..b2ead7a2b642533e2a833d59a83e68c9bb61accf 100644 (file)
@@ -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()