Fix directory separators to allow the Debug.caller() function to strip unnecessary...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 1 Apr 2006 11:30:40 +0000 (11:30 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 1 Apr 2006 11:30:40 +0000 (11:30 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1435 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Debug.py
src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Node/__init__.py

index cc97fe028ae57424a185d6b9720b7d10fcf7330b..1cff9c6c51b41a1b4c2fec4fc9cd4e9182ad9444 100644 (file)
@@ -31,10 +31,11 @@ needed by most users.
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-
-# Recipe 14.10 from the Python Cookbook.
+import os
 import string
 import sys
+
+# Recipe 14.10 from the Python Cookbook.
 try:
     import weakref
 except ImportError:
@@ -152,6 +153,12 @@ shorten_list = [
     ( '/usr/lib/python',        0),
 ]
 
+if os.sep != '/':
+   def platformize(t):
+       return (string.replace(t[0], '/', os.sep), t[1])
+   shorten_list = map(platformize, shorten_list)
+   del platformize
+
 def func_shorten(func_tuple):
     f = func_tuple[0]
     for t in shorten_list:
index c0a6186d925cdb7522d9da0b5d1de3a1ffc9fd70..5e01526b3d28a1aa738eaa64be1246108ba767fd 100644 (file)
@@ -1609,7 +1609,7 @@ class FileBuildInfo(SCons.Node.BuildInfoBase):
         SCons.Node.BuildInfoBase.__init__(self, node)
         self.node = node
     def convert_to_sconsign(self):
-        """Convert this BuildInfo object for writing to a .sconsign file
+        """Convert this FileBuildInfo object for writing to a .sconsign file
 
         We hung onto the node that we refer to so that we can translate
         the lists of bsources, bdepends and bimplicit Nodes into strings
@@ -1627,15 +1627,24 @@ class FileBuildInfo(SCons.Node.BuildInfoBase):
             else:
                 setattr(self, attr, map(rel_path, val))
     def convert_from_sconsign(self, dir, name):
-        """Convert a newly-read BuildInfo object for in-SCons use
-
-        An on-disk BuildInfo comes without a reference to the node
-        for which it's intended, so we have to convert the arguments
-        and add back a self.node attribute.  The bsources, bdepends and
-        bimplicit lists all come from disk as paths relative to that node,
-        so convert them to actual Nodes for use by the rest of SCons.
+        """Convert a newly-read FileBuildInfo object for in-SCons use
+
+        An on-disk BuildInfo comes without a reference to the node for
+        which it's intended, so we have to convert the arguments and add
+        back a self.node attribute.  We don't worry here about converting
+        the bsources, bdepends and bimplicit lists from strings to Nodes
+        because they're not used in the normal case of just deciding
+        whether or not to rebuild things.
         """
         self.node = dir.Entry(name)
+    def prepare_dependencies(self):
+        """Prepare a FileBuildInfo object for explaining what changed
+
+        The bsources, bdepends and bimplicit lists have all been stored
+        on disk as paths relative to the Node for which they're stored
+        as dependency info.  Convert the strings to actual Nodes (for
+        use by the --debug=explain code and --implicit-cache).
+        """
         Entry_func = self.node.dir.Entry
         for attr in ['bsources', 'bdepends', 'bimplicit']:
             try:
@@ -1755,6 +1764,7 @@ class File(Base):
 
     def get_stored_implicit(self):
         binfo = self.get_stored_info()
+        binfo.prepare_dependencies()
         try: return binfo.bimplicit
         except AttributeError: return None
 
index 321deaa30634048e706fc60ab8358cd782661879..f8512c929ec3751d7336a325f62a6abc0138f6a5 100644 (file)
@@ -777,9 +777,21 @@ class FileBuildInfoTestCase(_tempdirTestCase):
 
     def test_convert_to_sconsign(self):
         """Test converting to .sconsign file format"""
+        fff = self.fs.File('fff')
+        bi = SCons.Node.FS.FileBuildInfo(fff)
+        assert hasattr(bi, 'convert_to_sconsign')
 
     def test_convert_from_sconsign(self):
         """Test converting from .sconsign file format"""
+        fff = self.fs.File('fff')
+        bi = SCons.Node.FS.FileBuildInfo(fff)
+        assert hasattr(bi, 'convert_from_sconsign')
+
+    def test_prepare_dependencies(self):
+        """Test that we have a prepare_dependencies() method"""
+        fff = self.fs.File('fff')
+        bi = SCons.Node.FS.FileBuildInfo(fff)
+        bi.prepare_dependencies()
 
     def test_format(self):
         """Test the format() method"""
index 4af0ea13d354976033124ef8e327b50c45678218..3949abb43be588bdd91cd14cbb6785ce0dbd746e 100644 (file)
@@ -216,6 +216,11 @@ class Calculator:
 
 class NodeInfoBaseTestCase(unittest.TestCase):
 
+    def test_prepare_dependencies(self):
+        """Test that we have a prepare_dependencies() method"""
+        ni = SCons.Node.NodeInfoBase(SCons.Node.Node())
+        ni.prepare_dependencies()
+
     def test___cmp__(self):
         """Test comparing NodeInfoBase objects"""
         ni1 = SCons.Node.NodeInfoBase(SCons.Node.Node())
@@ -662,7 +667,8 @@ class NodeTestCase(unittest.TestCase):
 
         def get_null_info():
             class Null_BInfo:
-                pass
+                def prepare_dependencies(self):
+                    pass
             return Null_BInfo()
 
         node.get_stored_info = get_null_info
index 6af15018b81d91063c53152dc0dfabc36cff71bd..6f87a1a67b99d05b719189c781fbd3f628e34030 100644 (file)
@@ -116,6 +116,8 @@ class NodeInfoBase:
     def merge(self, other):
         for key, val in other.__dict__.items():
             self.__dict__[key] = val
+    def prepare_dependencies(self):
+        pass
     def format(self):
         try:
             field_list = self.field_list
@@ -1007,6 +1009,7 @@ class Node:
         old = self.get_stored_info()
         if old is None:
             return None
+        old.prepare_dependencies()
 
         def dictify(result, kids, sigs):
             for k, s in zip(kids, sigs):