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
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."
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."
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)
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:
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:
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.
"""