summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2005-06-04 16:43:13 (GMT)
committerSteven Knight <knight@baldmt.com>2005-06-04 16:43:13 (GMT)
commit7a75ef62e1067b6c8af61f1656c54f5d6853432c (patch)
tree72c9af859aaaca0b032d70fa89f09488a1870035 /src/engine/SCons/Node
parent97bdb1f4e23bac6d3b3d02f855c5a25882212afb (diff)
downloadSCons-7a75ef62e1067b6c8af61f1656c54f5d6853432c.zip
SCons-7a75ef62e1067b6c8af61f1656c54f5d6853432c.tar.gz
SCons-7a75ef62e1067b6c8af61f1656c54f5d6853432c.tar.bz2
Move BuildInfo translation of signature Nodes to rel_paths into the class itself.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r--src/engine/SCons/Node/FS.py53
-rw-r--r--src/engine/SCons/Node/NodeTests.py21
-rw-r--r--src/engine/SCons/Node/__init__.py14
3 files changed, 58 insertions, 30 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 07093d0..c728ece 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1465,12 +1465,52 @@ class RootDir(Dir):
return _null
class BuildInfo:
+ # bsig needs to stay here, if it's initialized in __init__() then
+ # the assignment overwrites any values read from .sconsign files.
bsig = None
+ def __init__(self, node):
+ self.node = node
def __cmp__(self, other):
try:
return cmp(self.bsig, other.bsig)
except AttributeError:
return 1
+ def convert_to_sconsign(self):
+ """Convert this BuildInfo 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
+ relative to the node, but we don't want to write out that Node
+ itself to the .sconsign file, so we delete the attribute in
+ preparation.
+ """
+ rel_path = self.node.rel_path
+ delattr(self, 'node')
+ for attr in ['bsources', 'bdepends', 'bimplicit']:
+ try:
+ val = getattr(self, attr)
+ except AttributeError:
+ pass
+ 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.
+ """
+ self.node = dir.Entry(name)
+ Entry_func = self.node.dir.Entry
+ for attr in ['bsources', 'bdepends', 'bimplicit']:
+ try:
+ val = getattr(self, attr)
+ except AttributeError:
+ pass
+ else:
+ setattr(self, attr, map(Entry_func, val))
class File(Base):
"""A class for files in a file system.
@@ -1537,7 +1577,7 @@ class File(Base):
try:
stored = self.dir.sconsign().get_entry(self.name)
except (KeyError, OSError):
- return BuildInfo()
+ return self.new_binfo()
else:
if isinstance(stored, BuildInfo):
return stored
@@ -1546,16 +1586,15 @@ class File(Base):
# 0.95 or before. The relevant attribute names are the same,
# though, so just copy the attributes over to an object of
# the correct type.
- binfo = BuildInfo()
+ binfo = self.new_binfo()
for key, val in stored.__dict__.items():
setattr(binfo, key, val)
return binfo
def get_stored_implicit(self):
binfo = self.get_stored_info()
- try: implicit = binfo.bimplicit
+ try: return binfo.bimplicit
except AttributeError: return None
- else: return map(self.dir.Entry, implicit)
def rel_path(self, other):
return self.dir.rel_path(other)
@@ -1727,7 +1766,7 @@ class File(Base):
return Base.exists(self)
def new_binfo(self):
- return BuildInfo()
+ return BuildInfo(self)
def del_cinfo(self):
try:
@@ -1759,7 +1798,7 @@ class File(Base):
if calc.max_drift >= 0:
old = self.get_stored_info()
else:
- old = BuildInfo()
+ old = self.new_binfo()
try:
mtime = self.get_timestamp()
@@ -1810,7 +1849,7 @@ class File(Base):
return None
else:
old = self.get_stored_info()
- return (old == self.binfo)
+ return (self.binfo == old)
def rfile(self):
"__cacheable__"
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index 70b9672..3be1d6b 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -503,24 +503,19 @@ class NodeTestCase(unittest.TestCase):
"""Test generating a build information structure
"""
node = SCons.Node.Node()
- binfo = node.gen_binfo(Calculator(666))
+ d = SCons.Node.Node()
+ i = SCons.Node.Node()
+ node.depends = [d]
+ node.implicit = [i]
+ binfo = node.gen_binfo(Calculator(1998))
assert isinstance(binfo, SCons.Node.BuildInfo), binfo
assert hasattr(binfo, 'bsources')
assert hasattr(binfo, 'bsourcesigs')
- assert hasattr(binfo, 'bdepends')
+ assert binfo.bdepends == [d]
assert hasattr(binfo, 'bdependsigs')
- assert hasattr(binfo, 'bimplicit')
+ assert binfo.bimplicit == [i]
assert hasattr(binfo, 'bimplicitsigs')
- assert binfo.bsig == 666, binfo.bsig
-
- def test_rel_path(self):
- """Test the rel_path() method
- """
- node = SCons.Node.Node()
- other = SCons.Node.Node()
- other.__str__ = lambda: "xyzzy"
- r = node.rel_path(other)
- assert r == "xyzzy", r
+ assert binfo.bsig == 5994, binfo.bsig
def test_explain(self):
"""Test explaining why a Node must be rebuilt
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index b9d5a75..627d020 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -574,7 +574,7 @@ class Node:
def calc_signature(node, calc=calc):
return node.calc_signature(calc)
- bsources = executor.process_sources(self.rel_path, self.ignore)
+ sources = executor.process_sources(None, self.ignore)
sourcesigs = executor.process_sources(calc_signature, self.ignore)
depends = self.depends
@@ -594,9 +594,9 @@ class Node:
binfo.bactsig = calc.module.signature(executor)
sigs.append(binfo.bactsig)
- binfo.bsources = bsources
- binfo.bdepends = map(self.rel_path, depends)
- binfo.bimplicit = map(self.rel_path, implicit)
+ binfo.bsources = sources
+ binfo.bdepends = depends
+ binfo.bimplicit = implicit
binfo.bsourcesigs = sourcesigs
binfo.bdependsigs = dependsigs
@@ -606,12 +606,6 @@ class Node:
return binfo
- def rel_path(self, other):
- # Using other.__str__() instead of str(other) lets the Memoizer
- # get the right method for the underlying Node object, not the
- # __str__() method for the Memoizer wrapper object.
- return other.__str__()
-
def del_cinfo(self):
try:
del self.binfo.csig