Generalize whether or not nodes use signatures, and how the Sig module decides if...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 15 Oct 2001 20:20:28 +0000 (20:20 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 15 Oct 2001 20:20:28 +0000 (20:20 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@101 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Node/__init__.py
src/engine/SCons/Sig/SigTests.py
src/engine/SCons/Sig/__init__.py

index e0941ad6dbc0c4b69b3984eee10cf1746328f900..e44da2266df296968f39d8595f637246248667b6 100644 (file)
@@ -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
index bf94e1f2e3dc3260aaba27e442f7f0fed2c6f213..fc0a0a30978ffe6a4a89df53c1824726545459b7 100644 (file)
@@ -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)
 
index 017b7f28c54e8991660c8fe1b93326892fc08b07..02b34b522b86b51ee3e55aba99714bfb82b7a269 100644 (file)
@@ -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
        """
index d6553e55797847fb2edeef6560795c24f0ddf403..265071ed8cad3c83a620040b035a243f4a822f22 100644 (file)
@@ -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
index 77a8a166eeb57cfcd95f044fa48cd50c7d211b3b..b42e464a874c1f15f465625243ac028c95ba637a 100644 (file)
@@ -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")
 
index 869cf8531d4906222651d12e663b077892f3d053..8e4ed56eb85e82dc4c0d20b13f599f9e0bf9aa67 100644 (file)
@@ -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)