diff options
author | Steven Knight <knight@baldmt.com> | 2002-07-21 07:15:23 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-07-21 07:15:23 (GMT) |
commit | 4656997675841eecc2fd51cad0034eb04152266e (patch) | |
tree | a664f104adf25d723df501dd8956e7422da39991 /src/engine/SCons/Node | |
parent | 392b862b57d335f6ac4539833d03fcecef0628f0 (diff) | |
download | SCons-4656997675841eecc2fd51cad0034eb04152266e.zip SCons-4656997675841eecc2fd51cad0034eb04152266e.tar.gz SCons-4656997675841eecc2fd51cad0034eb04152266e.tar.bz2 |
Refactor current() calculation so the Taskmaster passes the Sig calculator to the Node, instead of going through calc to get to the Node.
Diffstat (limited to 'src/engine/SCons/Node')
-rw-r--r-- | src/engine/SCons/Node/Alias.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 25 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 51 |
3 files changed, 68 insertions, 24 deletions
diff --git a/src/engine/SCons/Node/Alias.py b/src/engine/SCons/Node/Alias.py index c6159da..276750f 100644 --- a/src/engine/SCons/Node/Alias.py +++ b/src/engine/SCons/Node/Alias.py @@ -65,15 +65,17 @@ class Alias(SCons.Node.Node): def set_bsig(self, bsig): """An alias has no signature.""" - pass + self.bsig = None def set_csig(self, csig): """An alias has no signature.""" - pass + self.csig = None - def current(self): + def current(self, calc): """If all of our children were up-to-date, then this Alias was up-to-date, too.""" + # Allow the children to calculate their signatures. + calc.bsig(self) state = 0 for kid in self.children(None): s = kid.get_state() @@ -89,10 +91,10 @@ class Alias(SCons.Node.Node): pass def is_under(self, dir): - # Make Alias nodes get built regardless of - # what directory scons was run from. Alias nodes - # are outside the filesystem: - return 1 + # Make Alias nodes get built regardless of + # what directory scons was run from. Alias nodes + # are outside the filesystem: + return 1 default_ans = AliasNameSpace() diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index 9a75f34..0837ed3 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -381,7 +381,6 @@ class Entry(SCons.Node.Node): self.path_ = self.path self.abspath_ = self.abspath self.dir = directory - self.use_signature = 1 self.__doSrcpath(self.duplicate) self.srcpath_ = self.srcpath self.cwd = None # will hold the SConscript directory for target nodes @@ -438,14 +437,15 @@ class Entry(SCons.Node.Node): parents.append(self.dir) return parents - def current(self): + def current(self, calc): """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.""" + bsig = calc.bsig(self) if not self.exists(): return 0 - return None + return calc.current(self, bsig) def is_under(self, dir): if self is dir: @@ -489,7 +489,6 @@ class Dir(Entry): self.entries = {} self.entries['.'] = self self.entries['..'] = self.dir - self.use_signature = None self.builder = 1 self._sconsign = None @@ -536,19 +535,23 @@ class Dir(Entry): """A null "builder" for directories.""" pass + def calc_signature(self, calc): + """A directory has no signature.""" + return None + def set_bsig(self, bsig): """A directory has no signature.""" - pass + bsig = None def set_csig(self, csig): """A directory has no signature.""" - pass + csig = None def get_contents(self): """Return a fixed "contents" value of a directory.""" return '' - def current(self): + def current(self, calc): """If all of our children were up-to-date, then this directory was up-to-date, too.""" state = 0 @@ -706,10 +709,10 @@ class File(Entry): if not hasattr(self, '_rfile'): self._rfile = self if not os.path.isabs(self.path) and not os.path.isfile(self.path): - def file_node(path, fs = self.fs): - if os.path.isfile(path): - return fs.File(path) - return None + def file_node(path, fs = self.fs): + if os.path.isfile(path): + return fs.File(path) + return None n = self.fs.Rsearch(self.path, file_node) if n: self._rfile = n diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 2a5e5bc..45f5bc7 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -84,9 +84,6 @@ class Node: self.target_scanner = None # explicit scanner from this node's Builder self.env = None self.state = None - self.bsig = None - self.csig = None - self.use_signature = 1 self.precious = None self.found_includes = {} self.includes = None @@ -151,13 +148,13 @@ class Node: def get_parents(node, parent): return node.get_parents() def clear_cache(node, parent): node.implicit = None - node.bsig = None + node.del_bsig() w = Walker(self, get_parents, ignore_cycle, clear_cache) while w.next(): pass # clear out the content signature, since the contents of this # node were presumably just changed: - self.csig = None + self.del_csig() def depends_on(self, nodes): """Does this node depend on any of 'nodes'?""" @@ -217,7 +214,7 @@ class Node: # we need to recalculate the implicit deps, # and the bsig: self.implicit = [] - self.bsig = None + self.del_bsig() for child in self.children(scan=0): self._add_child(self.implicit, @@ -242,9 +239,39 @@ class Node: return self.env = env + def calc_signature(self, calc): + """ + Select and calculate the appropriate build signature for a node. + + self - the node + calc - the signature calculation module + returns - the signature + + This method does not store the signature in the node or + in the .sconsign file. + """ + + if self.builder: + if SCons.Sig.build_signature: + if not hasattr(self, 'bsig'): + self.set_bsig(calc.bsig(self)) + return self.get_bsig() + else: + if not hasattr(self, 'csig'): + self.set_csig(calc.csig(self)) + return self.get_csig() + elif not self.exists(): + return None + else: + if not hasattr(self, 'csig'): + self.set_csig(calc.csig(self)) + return self.get_csig() + def get_bsig(self): """Get the node's build signature (based on the signatures of its dependency files and build information).""" + if not hasattr(self, 'bsig'): + return None return self.bsig def set_bsig(self, bsig): @@ -257,8 +284,15 @@ class Node: .sconsign file or equivalent).""" pass + def del_bsig(self): + """Delete the bsig from this node.""" + if hasattr(self, 'bsig'): + delattr(self, 'bsig') + def get_csig(self): """Get the signature of the node's content.""" + if not hasattr(self, 'csig'): + return None return self.csig def set_csig(self, csig): @@ -270,6 +304,11 @@ class Node: .sconsign file or equivalent).""" pass + def del_csig(self): + """Delete the csig from this node.""" + if hasattr(self, 'csig'): + delattr(self, 'csig') + def get_prevsiginfo(self): """Fetch the previous signature information from the .sconsign entry.""" |