From ae4c16a8799bb044527f10ea00c75559e74e1060 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Wed, 7 Apr 2004 22:58:22 +0000 Subject: [PATCH] Have Task.make_ready() create a list of the out-of-date Nodes. git-svn-id: http://scons.tigris.org/svn/scons/trunk@951 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 ++ src/engine/SCons/Taskmaster.py | 25 ++++++++++------ src/engine/SCons/TaskmasterTests.py | 44 +++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 8 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 45295c6d..a7323ea7 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -64,6 +64,9 @@ RELEASE 0.96 - XXX the env.SourceCode() method was called with an individual file name or node, not a directory name or node. + - Enhance the Task.make_ready() method to create a list of the + out-of-date Nodes for the task for use by the wrapping interface. + From Gary Oberbrunner: - Add a --debug=presub option to print actions prior to substitution. diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 8afd8471..ffdc065a 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -169,17 +169,26 @@ class Task: def make_ready(self): """Make a task ready for execution.""" - state = SCons.Node.up_to_date + self.out_of_date = [] calc = self.tm.calc - for t in self.targets: - c = calc or t.calculator() - if not t.current(c): - state = SCons.Node.executing - for t in self.targets: - if state == SCons.Node.executing: + if calc: + for t in self.targets: + if not t.current(calc): + self.out_of_date.append(t) + else: + for t in self.targets: + if not t.current(t.calculator()): + self.out_of_date.append(t) + if self.out_of_date: + state = SCons.Node.executing + for t in self.targets: for side_effect in t.side_effects: side_effect.set_state(state) - t.set_state(state) + t.set_state(state) + else: + state = SCons.Node.up_to_date + for t in self.targets: + t.set_state(state) def postprocess(self): """Post process a task after it's been executed.""" diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py index d20b805b..1f66e06b 100644 --- a/src/engine/SCons/TaskmasterTests.py +++ b/src/engine/SCons/TaskmasterTests.py @@ -23,6 +23,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import copy import sys import unittest @@ -409,6 +410,49 @@ class TaskmasterTestCase(unittest.TestCase): t.executed() + def test_make_ready_out_of_date(self): + """Test the Task.make_ready() method's list of out-of-date Nodes + """ + class MyCalc(SCons.Taskmaster.Calc): + def current(self, node, sig): + n = str(node) + return n[0] == 'c' + + ood = [] + def TaskGen(tm, targets, top, node, ood=ood): + class MyTask(SCons.Taskmaster.Task): + def make_ready(self): + SCons.Taskmaster.Task.make_ready(self) + self.ood.extend(self.out_of_date) + t = MyTask(tm, targets, top, node) + t.ood = ood + return t + + n1 = Node("n1") + c2 = Node("c2") + n3 = Node("n3") + c4 = Node("c4") + tm = SCons.Taskmaster.Taskmaster(targets = [n1, c2, n3, c4], + tasker = TaskGen, + calc = MyCalc()) + + del ood[:] + t = tm.next_task() + assert ood == [n1], ood + + del ood[:] + t = tm.next_task() + assert ood == [], ood + + del ood[:] + t = tm.next_task() + assert ood == [n3], ood + + del ood[:] + t = tm.next_task() + assert ood == [], ood + + def test_make_ready_exception(self): """Test handling exceptions from Task.make_ready() """ -- 2.26.2