From 53dc2a1d84cd2922f0921dc16ca4633769980982 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Mon, 15 Oct 2001 20:20:28 +0000 Subject: [PATCH] Generalize whether or not nodes use signatures, and how the Sig module decides if a node is current before calculatin a signature. git-svn-id: http://scons.tigris.org/svn/scons/trunk@101 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Node/FS.py | 21 ++++++++++++++++++--- src/engine/SCons/Node/FSTests.py | 3 +++ src/engine/SCons/Node/NodeTests.py | 4 ++++ src/engine/SCons/Node/__init__.py | 4 ++++ src/engine/SCons/Sig/SigTests.py | 11 ++++++++++- src/engine/SCons/Sig/__init__.py | 17 +++++++++++++---- 6 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index e0941ad6..e44da226 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -252,7 +252,7 @@ class Entry(Node): else: self.abspath = self.path = name self.parent = directory - self.uses_signature = 1 + self.use_signature = 1 def __str__(self): """A FS node's string representation is its path name.""" @@ -261,7 +261,16 @@ class Entry(Node): def exists(self): return os.path.exists(self.path) - + def current(self): + """If the underlying path doesn't exist, we know the node is + not current without even checking the signature, so return 0. + Otherwise, return None to indicate that signature calculation + should proceed as normal to find out if the node is current.""" + if not self.exists(): + return 0 + return None + + # XXX TODO? # Annotate with the creator @@ -300,7 +309,7 @@ class Dir(Entry): delattr(self, 'parent') else: self.entries['..'] = None - self.uses_signature = None + self.use_signature = None def up(self): return self.entries['..'] @@ -316,6 +325,12 @@ class Dir(Entry): filter(lambda k: k != '.' and k != '..', self.entries.keys())) + def current(self): + """Always return that a directory node is out-of-date so + that it will always be "built" by trying to build all of + its directory entries.""" + return 0 + # XXX TODO? # rfile diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index bf94e1f2..fc0a0a30 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -95,6 +95,9 @@ class FSTestCase(unittest.TestCase): f1 = fs.File('f1', directory = d1) + assert d1.current() == 0 + assert f1.current() == 0 + assert f1.path == 'd1/f1', "f1.path %s != d1/f1" % f1.path assert str(f1) == 'd1/f1', "str(f1) %s != d1/f1" % str(f1) diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 017b7f28..02b34b52 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -89,6 +89,10 @@ class NodeTestCase(unittest.TestCase): node.builder_set(b) assert node.builder == b + def test_current(self): + node = SCons.Node.Node() + assert node.current() is None + def test_env_set(self): """Test setting a Node's Environment """ diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index d6553e55..265071ed 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -54,6 +54,7 @@ class Node: self.builder = None self.env = None self.state = None + self.use_signature = 1 def build(self): if not self.builder: @@ -105,6 +106,9 @@ class Node: def get_state(self): return self.state + def current(self): + return None + class Wrapper: def __init__(self, node): self.node = node diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py index 77a8a166..b42e464a 100644 --- a/src/engine/SCons/Sig/SigTests.py +++ b/src/engine/SCons/Sig/SigTests.py @@ -51,6 +51,7 @@ class DummyNode: self.path = file.path self.builder = file.builder self.depends = [] + self.use_signature = 1 def get_contents(self): # a file that doesn't exist has no contents: @@ -66,7 +67,15 @@ class DummyNode: def exists(self): return not self.file.contents is None - + + def children(self): + return self.sources + self.depends + + def current(self): + if not self.exists(): + return 0 + return None + def has_signature(self): return hasattr(self, "sig") diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 869cf853..8e4ed56e 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -114,7 +114,7 @@ class Calculator: signatures - the dictionary that the signatures will be gathered into. """ - for source_node in node.sources + node.depends: + for source_node in node.children(): if not signatures.has_key(source_node): signature = self.signature(source_node) signatures[source_node] = signature @@ -145,7 +145,11 @@ class Calculator: in the .sconsign file. """ - if node.has_signature(): + if not node.use_signature: + # This node type doesn't use a signature (e.g. a + # directory) so bail right away. + return None + elif node.has_signature(): sig = node.get_signature() elif node.builder: signatures = {} @@ -184,8 +188,13 @@ class Calculator: and 1 if it hasn't """ - if not node.exists(): - return 0 + c = node.current() + if not c is None: + # The node itself has told us whether or not it's + # current without checking the signature. The + # canonical uses here are a "0" return for a file + # that doesn't exist, or a directory. + return c dir, filename = os.path.split(node.path) oldtime, oldsig = self.get_sig_file(dir).get(filename) -- 2.26.2