summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Node
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-06-15 12:54:45 (GMT)
committerSteven Knight <knight@baldmt.com>2004-06-15 12:54:45 (GMT)
commitf0bf250b85abbe23faa7eeff0e53beb0613a2c6f (patch)
tree96cf9c87582bafacbe731704f4f10fbd8e34d331 /src/engine/SCons/Node
parenta0d7c6333aeb9b6f2848ea3c90662f91f7f8ac0e (diff)
downloadSCons-f0bf250b85abbe23faa7eeff0e53beb0613a2c6f.zip
SCons-f0bf250b85abbe23faa7eeff0e53beb0613a2c6f.tar.gz
SCons-f0bf250b85abbe23faa7eeff0e53beb0613a2c6f.tar.bz2
Add an option to not save the --debug=explain information.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r--src/engine/SCons/Node/FS.py29
-rw-r--r--src/engine/SCons/Node/FSTests.py50
-rw-r--r--src/engine/SCons/Node/NodeTests.py14
-rw-r--r--src/engine/SCons/Node/__init__.py32
4 files changed, 112 insertions, 13 deletions
diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py
index 23cf8a7..2f115c9 100644
--- a/src/engine/SCons/Node/FS.py
+++ b/src/engine/SCons/Node/FS.py
@@ -1385,7 +1385,34 @@ class File(Base):
return 0
def store_info(self, obj):
- self.dir.sconsign().set_entry(self.name, obj)
+ # Merge our build information into the already-stored entry.
+ # This accomodates "chained builds" where a file that's a target
+ # in one build (SConstruct file) is a source in a different build.
+ # See test/chained-build.py for the use case.
+ entry = self.get_stored_info()
+ if not SCons.Node.Save_Explain_Info:
+ # If we're not saving explanation info, wipe out any that
+ # might be in the already-stored entry.
+ #
+ # XXX This is kind of bad that we're naming attributes that
+ # are really controlled in Node/__init__.py. It would be
+ # good to find a way to move this logic there in some way
+ # that still accounts for the fact that not all Node classes
+ # need or use this information.
+ attributes = [
+ 'bsources', 'bsourcesigs',
+ 'bdepends', 'bdependsigs',
+ 'bimplicit', 'bimplicitsigs',
+ 'bact', 'bactsig',
+ ]
+ for attr in attributes:
+ try:
+ delattr(entry, attr)
+ except AttributeError:
+ pass
+ for key, val in obj.__dict__.items():
+ entry.__dict__[key] = val
+ sconsign = self.dir.sconsign().set_entry(self.name, entry)
def get_stored_info(self):
try:
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index d9ffd83..d4137c1 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -1969,6 +1969,55 @@ class SaveStringsTestCase(unittest.TestCase):
expect = map(os.path.normpath, ['src/f', 'd1/f', 'd0/b', 'd1/b'])
assert s == expect, s
+class SaveExplainInfoTestCase(unittest.TestCase):
+ def runTest(self):
+ """Test how we store --debug=explain info."""
+ test=TestCmd(workdir='')
+ fs = SCons.Node.FS.FS(test.workpath('fs'))
+ f = fs.File('file')
+
+ class BInfo:
+ pass
+
+ bi = BInfo()
+ bi.bact = 'file bact'
+ bi.arg1 = 'file arg1'
+ f.store_info(bi)
+
+ i = f.get_stored_info()
+ assert i.bact == 'file bact', i.arg1
+ assert i.arg1 == 'file arg1', i.arg1
+ assert not hasattr(i, 'arg2'), i.bact
+ assert not hasattr(i, 'arg3'), i.bact
+
+ save_value = SCons.Node.Save_Explain_Info
+ try:
+ SCons.Node.Save_Explain_Info = 1
+
+ bi = BInfo()
+ bi.arg2 = 'file arg2'
+ f.store_info(bi)
+
+ i = f.get_stored_info()
+ assert i.bact == 'file bact', i.arg1
+ assert i.arg1 == 'file arg1', i.arg1
+ assert i.arg2 == 'file arg2', i.arg2
+ assert not hasattr(i, 'arg3'), i.bact
+
+ SCons.Node.Save_Explain_Info = 0
+
+ bi = BInfo()
+ bi.arg3 = 'file arg3'
+ f.store_info(bi)
+
+ i = f.get_stored_info()
+ assert not hasattr(i, 'bact'), i.bact
+ assert i.arg1 == 'file arg1', i.arg1
+ assert i.arg2 == 'file arg2', i.arg2
+ assert i.arg3 == 'file arg3', i.arg2
+ finally:
+ SCons.Node.Save_Explain_Info = save_value
+
if __name__ == "__main__":
@@ -1989,5 +2038,6 @@ if __name__ == "__main__":
suite.addTest(postprocessTestCase())
suite.addTest(SpecialAttrTestCase())
suite.addTest(SaveStringsTestCase())
+ suite.addTest(SaveExplainInfoTestCase())
if not unittest.TextTestRunner().run(suite).wasSuccessful():
sys.exit(1)
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index 4c7d9c2..cd7aa18 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -396,6 +396,7 @@ class NodeTestCase(unittest.TestCase):
def collect(self, args):
return reduce(lambda x, y: x+y, args, self.val)
self.module = M(val)
+
node = SCons.Node.Node()
binfo = node.gen_binfo(Calculator(666))
assert isinstance(binfo, SCons.Node.BuildInfo), binfo
@@ -407,6 +408,19 @@ class NodeTestCase(unittest.TestCase):
assert hasattr(binfo, 'bimplicitsigs')
assert binfo.bsig == 666, binfo.bsig
+ SCons.Node.Save_Explain_Info = 0
+
+ node = SCons.Node.Node()
+ binfo = node.gen_binfo(Calculator(777))
+ assert isinstance(binfo, SCons.Node.BuildInfo), binfo
+ assert not hasattr(binfo, 'bsources')
+ assert not hasattr(binfo, 'bsourcesigs')
+ assert not hasattr(binfo, 'bdepends')
+ assert not hasattr(binfo, 'bdependsigs')
+ assert not hasattr(binfo, 'bimplicit')
+ assert not hasattr(binfo, 'bimplicitsigs')
+ assert binfo.bsig == 777, 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 ba4cbca..64226a6 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -76,6 +76,9 @@ implicit_deps_unchanged = 0
# controls whether the cached implicit deps are ignored:
implicit_deps_changed = 0
+# controls whether --debug=explain info is saved in Nodes:
+Save_Explain_Info = 1
+
# A variable that can be set to an interface-specific function be called
# to annotate a Node with information about its creation.
def do_nothing(node): pass
@@ -542,21 +545,26 @@ class Node:
dependsigs = map(calc_signature, depends)
implicitsigs = map(calc_signature, implicit)
- binfo.bsources = map(str, sources)
- binfo.bdepends = map(str, depends)
- binfo.bimplicit = map(str, implicit)
-
- binfo.bsourcesigs = sourcesigs
- binfo.bdependsigs = dependsigs
- binfo.bimplicitsigs = implicitsigs
-
sigs = sourcesigs + dependsigs + implicitsigs
- if self.has_builder():
+ has_builder = self.has_builder()
+ if has_builder:
executor = self.get_executor()
- binfo.bact = str(executor)
- binfo.bactsig = calc.module.signature(executor)
- sigs.append(binfo.bactsig)
+ bactsig = calc.module.signature(executor)
+ sigs.append(bactsig)
+
+ if Save_Explain_Info:
+ binfo.bsources = map(str, sources)
+ binfo.bdepends = map(str, depends)
+ binfo.bimplicit = map(str, implicit)
+
+ binfo.bsourcesigs = sourcesigs
+ binfo.bdependsigs = dependsigs
+ binfo.bimplicitsigs = implicitsigs
+
+ if has_builder:
+ binfo.bact = str(executor)
+ binfo.bactsig = calc.module.signature(executor)
binfo.bsig = calc.module.collect(filter(None, sigs))