diff options
author | Steven Knight <knight@baldmt.com> | 2006-04-01 11:30:40 +0000 |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2006-04-01 11:30:40 +0000 |
commit | 5e36fe4beb10b2d7819ba54f91bfec03ec67f646 (patch) | |
tree | 2f7812957ecd562c1a41f3620121c474fde5cef5 /src/engine | |
parent | 7939be2bdec408bc2596f549f73ca307b62bdf2b (diff) | |
download | scons-5e36fe4beb10b2d7819ba54f91bfec03ec67f646.tar.gz |
Fix directory separators to allow the Debug.caller() function to strip unnecessary parts of path names on Windows.
Diffstat (limited to 'src/engine')
-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 cc97fe02..1cff9c6c 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 c0a6186d..5e01526b 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 321deaa3..f8512c92 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 4af0ea13..3949abb4 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 6af15018..6f87a1a6 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): |