summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-05-08 22:56:08 (GMT)
committerSteven Knight <knight@baldmt.com>2004-05-08 22:56:08 (GMT)
commitf424fc07e9aed44d3f5df0a14d4b44081c806ff1 (patch)
tree8830c93a12c2f2919c66c0f92ec736f9b85bceda /src
parentb155ebc4a869e0669ee2f7124531e0b5950c7528 (diff)
downloadSCons-f424fc07e9aed44d3f5df0a14d4b44081c806ff1.zip
SCons-f424fc07e9aed44d3f5df0a14d4b44081c806ff1.tar.gz
SCons-f424fc07e9aed44d3f5df0a14d4b44081c806ff1.tar.bz2
Cleaner Task interface when using the -c option.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Script/__init__.py18
-rw-r--r--src/engine/SCons/Taskmaster.py23
-rw-r--r--src/engine/SCons/TaskmasterTests.py65
3 files changed, 92 insertions, 14 deletions
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index 3a7d4c1..7978629 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -267,6 +267,11 @@ class CleanTask(SCons.Taskmaster.Task):
execute = remove
+ # Have the taskmaster arrange to "execute" all of the targets, because
+ # we'll figure out ourselves (in remove() or show() above) whether
+ # anything really needs to be done.
+ make_ready = SCons.Taskmaster.Task.make_ready_all
+
def prepare(self):
pass
@@ -1051,7 +1056,6 @@ def _main(args, parser):
nodes = filter(lambda x: x is not None, map(Entry, targets))
- calc = None
task_class = BuildTask # default action is to build targets
opening_message = "Building targets ..."
closing_message = "done building targets."
@@ -1061,16 +1065,6 @@ def _main(args, parser):
try:
if ssoptions.get('clean'):
task_class = CleanTask
- class CleanCalculator:
- def bsig(self, node):
- return None
- def csig(self, node):
- return None
- def current(self, node, sig):
- return 0
- def write(self):
- pass
- calc = CleanCalculator()
opening_message = "Cleaning targets ..."
closing_message = "done cleaning targets."
failure_message = "cleaning terminated because of errors."
@@ -1095,7 +1089,7 @@ def _main(args, parser):
return dependencies
progress_display("scons: " + opening_message)
- taskmaster = SCons.Taskmaster.Taskmaster(nodes, task_class, calc, order)
+ taskmaster = SCons.Taskmaster.Taskmaster(nodes, task_class, None, order)
nj = ssoptions.get('num_jobs')
jobs = SCons.Job.Jobs(nj, taskmaster)
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py
index ffdc065..e5b3548 100644
--- a/src/engine/SCons/Taskmaster.py
+++ b/src/engine/SCons/Taskmaster.py
@@ -167,8 +167,25 @@ class Task:
self.tm.executed(self.node)
- def make_ready(self):
- """Make a task ready for execution."""
+ def make_ready_all(self):
+ """Mark all targets in a task ready for execution.
+
+ This is used when the interface needs every target Node to be
+ visited--the canonical example being the "scons -c" option.
+ """
+ self.out_of_date = self.targets[:]
+ 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)
+
+ def make_ready_current(self):
+ """Mark all targets in a task ready for execution if any target
+ is not current.
+
+ This is the default behavior for building only what's necessary.
+ """
self.out_of_date = []
calc = self.tm.calc
if calc:
@@ -190,6 +207,8 @@ class Task:
for t in self.targets:
t.set_state(state)
+ make_ready = make_ready_current
+
def postprocess(self):
"""Post process a task after it's been executed."""
for t in self.targets:
diff --git a/src/engine/SCons/TaskmasterTests.py b/src/engine/SCons/TaskmasterTests.py
index 1f66e06..8ca7e86 100644
--- a/src/engine/SCons/TaskmasterTests.py
+++ b/src/engine/SCons/TaskmasterTests.py
@@ -470,6 +470,71 @@ class TaskmasterTestCase(unittest.TestCase):
assert str(e.value) == "from make_ready()", str(e.value)
+ def test_make_ready_all(self):
+ class MyCalc(SCons.Taskmaster.Calc):
+ def current(self, node, sig):
+ n = str(node)
+ return n[0] == 'c'
+
+ class MyTask(SCons.Taskmaster.Task):
+ make_ready = SCons.Taskmaster.Task.make_ready_all
+
+ n1 = Node("n1")
+ c2 = Node("c2")
+ n3 = Node("n3")
+ c4 = Node("c4")
+
+ tm = SCons.Taskmaster.Taskmaster(targets = [n1, c2, n3, c4],
+ calc = MyCalc())
+
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is n1, target
+ assert target.state == SCons.Node.executing, target.state
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is c2, target
+ assert target.state == SCons.Node.up_to_date, target.state
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is n3, target
+ assert target.state == SCons.Node.executing, target.state
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is c4, target
+ assert target.state == SCons.Node.up_to_date, target.state
+ t = tm.next_task()
+ assert t is None
+
+ n1 = Node("n1")
+ c2 = Node("c2")
+ n3 = Node("n3")
+ c4 = Node("c4")
+
+ tm = SCons.Taskmaster.Taskmaster(targets = [n1, c2, n3, c4],
+ tasker = MyTask,
+ calc = MyCalc())
+
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is n1, target
+ assert target.state == SCons.Node.executing, target.state
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is c2, target
+ assert target.state == SCons.Node.executing, target.state
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is n3, target
+ assert target.state == SCons.Node.executing, target.state
+ t = tm.next_task()
+ target = t.get_target()
+ assert target is c4, target
+ assert target.state == SCons.Node.executing, target.state
+ t = tm.next_task()
+ assert t is None
+
+
def test_children_errors(self):
"""Test errors when fetching the children of a node.
"""