if not self.is_enabled():
return False
- retrieved = False
-
+ env = node.get_build_env()
if cache_show:
- if CacheRetrieveSilent(node, [], node.get_build_env(), execute=1) == 0:
+ if CacheRetrieveSilent(node, [], env, execute=1) == 0:
node.build(presub=0, execute=0)
- retrieved = 1
+ return True
else:
- if CacheRetrieve(node, [], node.get_build_env(), execute=1) == 0:
- retrieved = 1
- if retrieved:
- # Record build signature information, but don't
- # push it out to cache. (We just got it from there!)
- node.set_state(SCons.Node.executed)
- SCons.Node.Node.built(node)
-
- return retrieved
+ if CacheRetrieve(node, [], env, execute=1) == 0:
+ return True
+
+ return False
def push(self, node):
if not self.is_enabled():
cd_f3 = self.test.workpath("cd.f3")
f3 = self.File(cd_f3)
- f3.built()
+ f3.push_to_cache()
assert self.pushed == [], self.pushed
self.test.write(cd_f3, "cd.f3\n")
- f3.built()
+ f3.push_to_cache()
assert self.pushed == [f3], self.pushed
self.pushed = []
warn_caught = 0
try:
- f7.built()
+ f7.push_to_cache()
except SCons.Errors.BuildError, e:
assert e.exc_info[0] == SCons.Warnings.CacheWriteErrorWarning
warn_caught = 1
# created.
self.dir._create()
+ def push_to_cache(self):
+ """Try to push the node into a cache
+ """
+ # This should get called before the Nodes' .built() method is
+ # called, which would clear the build signature if the file has
+ # a source scanner.
+ #
+ # We have to clear the local memoized values *before* we push
+ # the node to cache so that the memoization of the self.exists()
+ # return value doesn't interfere.
+ if self.nocache:
+ return
+ self.clear_memoized_values()
+ if self.exists():
+ self.get_build_env().get_CacheDir().push(self)
+
def retrieve_from_cache(self):
"""Try to retrieve the node's content from a cache
return None
return self.get_build_env().get_CacheDir().retrieve(self)
- def built(self):
- """
- Called just after this node is successfully built.
- """
- # Push this file out to cache before the superclass Node.built()
- # method has a chance to clear the build signature, which it
- # will do if this file has a source scanner.
- #
- # We have to clear the memoized values *before* we push it to
- # cache so that the memoization of the self.exists() return
- # value doesn't interfere.
- self.clear_memoized_values()
- if self.exists():
- self.get_build_env().get_CacheDir().push(self)
- SCons.Node.Node.built(self)
-
def visited(self):
if self.exists():
self.get_build_env().get_CacheDir().push_if_forced(self)
assert n.cleared, n.cleared
assert n.ninfo.updated, n.ninfo.cleared
+ def test_push_to_cache(self):
+ """Test the base push_to_cache() method"""
+ n = SCons.Node.Node()
+ r = n.push_to_cache()
+ assert r is None, r
+
def test_retrieve_from_cache(self):
"""Test the base retrieve_from_cache() method"""
n = SCons.Node.Node()
except AttributeError:
pass
+ def push_to_cache(self):
+ """Try to push a node into a cache
+ """
+ pass
+
def retrieve_from_cache(self):
"""Try to retrieve the node's content from a cache
return None
def prepare(self):
pass
+ def push_to_cache(self):
+ pass
def retrieve_from_cache(self):
return 0
def build(self, **kw):
try:
everything_was_cached = 1
for t in self.targets:
- if not t.retrieve_from_cache():
+ if t.retrieve_from_cache():
+ # Call the .built() method without calling the
+ # .push_to_cache() method, since we just got the
+ # target from the cache and don't need to push
+ # it back there.
+ t.set_state(NODE_EXECUTED)
+ t.built()
+ else:
everything_was_cached = 0
break
if not everything_was_cached:
for side_effect in t.side_effects:
side_effect.set_state(NODE_NO_STATE)
t.set_state(NODE_EXECUTED)
+ t.push_to_cache()
t.built()
t.visited()
def disambiguate(self):
return self
+ def push_to_cache(self):
+ pass
+
def retrieve_from_cache(self):
global cache_text
if self.cached:
def built(self):
global built_text
- built_text = built_text + " really"
+ if not self.cached:
+ built_text = built_text + " really"
def has_builder(self):
return not self.builder is None