diff options
author | Steven Knight <knight@baldmt.com> | 2006-04-01 11:30:40 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2006-04-01 11:30:40 (GMT) |
commit | 2d6a08b6b461e7fc08d9b53bbd2db5b32a26f9ce (patch) | |
tree | 2f7812957ecd562c1a41f3620121c474fde5cef5 /src | |
parent | bc3363b11fdfb05a6baae87b6cf15458f193f77f (diff) | |
download | SCons-2d6a08b6b461e7fc08d9b53bbd2db5b32a26f9ce.zip SCons-2d6a08b6b461e7fc08d9b53bbd2db5b32a26f9ce.tar.gz SCons-2d6a08b6b461e7fc08d9b53bbd2db5b32a26f9ce.tar.bz2 |
Fix directory separators to allow the Debug.caller() function to strip unnecessary parts of path names on Windows.
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/Debug.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 26 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 12 | ||||
-rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 8 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 3 |
5 files changed, 49 insertions, 11 deletions
diff --git a/src/engine/SCons/Debug.py b/src/engine/SCons/Debug.py index cc97fe0..1cff9c6 100644 --- a/src/engine/SCons/Debug.py +++ b/src/engine/SCons/Debug.py @@ -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: diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index c0a6186..5e01526 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -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 diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 321deaa..f8512c9 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -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""" diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 4af0ea1..3949abb 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -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 diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 6af1501..6f87a1a 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -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): |