diff options
Diffstat (limited to 'src/engine/SCons/Sig/__init__.py')
-rw-r--r-- | src/engine/SCons/Sig/__init__.py | 68 |
1 files changed, 17 insertions, 51 deletions
diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 8e4ed56..36bceba 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -32,6 +32,15 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os.path import string + +#XXX Get rid of the global array so this becomes re-entrant. +sig_files = [] + +def write(): + global sig_files + for sig_file in sig_files: + sig_file.write() + class SConsignFile: """ Encapsulates reading and writing a .sconsign file. @@ -56,6 +65,9 @@ class SConsignFile: time, signature = map(string.strip, string.split(rest, " ")) self.entries[filename] = (int(time), module.from_string(signature)) + global sig_files + sig_files.append(self) + def get(self, filename): """ Get the signature for a file @@ -103,7 +115,6 @@ class Calculator: module - the signature module to use for signature calculations """ self.module = module - self.sig_files = {} def collect(self, node, signatures): @@ -116,24 +127,11 @@ class Calculator: """ for source_node in node.children(): if not signatures.has_key(source_node): - signature = self.signature(source_node) + signature = self.get_signature(source_node) signatures[source_node] = signature self.collect(source_node, signatures) - def get_sig_file(self, dir): - """ - Get a sconsign file from the cache, or add it to the cache. - - dir - the dir for the sconsign file - returns - the sconsign file - """ - if self.sig_files.has_key(dir): - return self.sig_files[dir] - else: - self.sig_files[dir] = SConsignFile(dir, self.module) - return self.sig_files[dir] - - def signature(self, node): + def get_signature(self, node): """ Get the signature for a node. @@ -141,7 +139,7 @@ class Calculator: returns - the signature or None if the signature could not be computed. - This method also stores the signature in the node and + This method does not store the signature in the node and in the .sconsign file. """ @@ -163,22 +161,9 @@ class Calculator: # XXX handle nodes that are not under the source root sig = self.module.signature(node) - node.set_signature(sig) - - dir, filename = os.path.split(node.path) - if node.exists(): - timestamp = node.get_timestamp() - else: - timestamp = 0 - - self.get_sig_file(dir).set(filename, - timestamp, - sig, - self.module) - return sig - def current(self, node): + def current(self, node, newsig): """ Check if a node is up to date. @@ -196,30 +181,11 @@ class Calculator: # 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) + oldtime, oldsig = node.get_oldentry() newtime = node.get_timestamp() if not node.builder and newtime == oldtime: newsig = oldsig - else: - newsig = self.signature(node) return self.module.current(newsig, oldsig) - - def write(self, nodes): - """ - Write out all of the signature files. - - nodes - the nodes whose signatures may have changed durring - the build - """ - - # make sure all the signatures have been calculated: - for node in nodes: - self.signature(node) - - for sig_file in self.sig_files.values(): - sig_file.write() - |