__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:
( '/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:
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
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:
def get_stored_implicit(self):
binfo = self.get_stored_info()
+ binfo.prepare_dependencies()
try: return binfo.bimplicit
except AttributeError: return None
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"""
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())
def get_null_info():
class Null_BInfo:
- pass
+ def prepare_dependencies(self):
+ pass
return Null_BInfo()
node.get_stored_info = get_null_info
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
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):