def GetBuildFailures():
return _BuildFailures
-class BuildTask(SCons.Taskmaster.Task):
+class BuildTask(SCons.Taskmaster.OutOfDateTask):
"""An SCons build task."""
progress = ProgressObject
def prepare(self):
self.progress(self.targets[0])
- return SCons.Taskmaster.Task.prepare(self)
+ return SCons.Taskmaster.OutOfDateTask.prepare(self)
def needs_execute(self):
- target = self.targets[0]
- if target.get_state() == SCons.Node.executing:
+ if SCons.Taskmaster.OutOfDateTask.needs_execute(self):
return True
- else:
- if self.top and target.has_builder():
- display("scons: `%s' is up to date." % str(self.node))
- return False
+ if self.top and self.targets[0].has_builder():
+ display("scons: `%s' is up to date." % str(self.node))
+ return False
def execute(self):
if print_time:
global first_command_start
if first_command_start is None:
first_command_start = start_time
- SCons.Taskmaster.Task.execute(self)
+ SCons.Taskmaster.OutOfDateTask.execute(self)
if print_time:
global cumulative_command_time
global last_command_end
global exit_status
global this_build_status
if self.options.ignore_errors:
- SCons.Taskmaster.Task.executed(self)
+ SCons.Taskmaster.OutOfDateTask.executed(self)
elif self.options.keep_going:
- SCons.Taskmaster.Task.fail_continue(self)
+ SCons.Taskmaster.OutOfDateTask.fail_continue(self)
exit_status = status
this_build_status = status
else:
- SCons.Taskmaster.Task.fail_stop(self)
+ SCons.Taskmaster.OutOfDateTask.fail_stop(self)
exit_status = status
this_build_status = status
self.do_failed()
else:
print "scons: Nothing to be done for `%s'." % t
- SCons.Taskmaster.Task.executed(self)
+ SCons.Taskmaster.OutOfDateTask.executed(self)
else:
- SCons.Taskmaster.Task.executed(self)
+ SCons.Taskmaster.OutOfDateTask.executed(self)
def failed(self):
# Handle the failure of a build task. The primary purpose here
if tree:
print
print tree
- SCons.Taskmaster.Task.postprocess(self)
+ SCons.Taskmaster.OutOfDateTask.postprocess(self)
def make_ready(self):
"""Make a task ready for execution"""
- SCons.Taskmaster.Task.make_ready(self)
+ SCons.Taskmaster.OutOfDateTask.make_ready(self)
if self.out_of_date and self.options.debug_explain:
explanation = self.out_of_date[0].explain()
if explanation:
sys.stdout.write("scons: " + explanation)
-class CleanTask(SCons.Taskmaster.Task):
+class CleanTask(SCons.Taskmaster.AlwaysTask):
"""An SCons clean task."""
def fs_delete(self, path, pathstr, remove=1):
try:
def prepare(self):
pass
-class QuestionTask(SCons.Taskmaster.Task):
+class QuestionTask(SCons.Taskmaster.AlwaysTask):
"""An SCons task for the -q (question) option."""
def prepare(self):
pass
-
+
def execute(self):
if self.targets[0].get_state() != SCons.Node.up_to_date or \
(self.top and not self.targets[0].exists()):
return self.node
def needs_execute(self):
- """
- Called to determine whether the task's execute() method should
- be run.
-
- This method allows one to skip the somethat costly execution
- of the execute() method in a seperate thread. For example,
- that would be unnecessary for up-to-date targets.
- """
+ # TODO(deprecate): "return True" is the old default behavior;
+ # change it to NotImplementedError (after running through the
+ # Deprecation Cycle) so the desired behavior is explicitly
+ # determined by which concrete subclass is used.
+ #raise NotImplementedError
return True
def execute(self):
exc_traceback = None
raise exc_type, exc_value, exc_traceback
+class AlwaysTask(Task):
+ def needs_execute(self):
+ """
+ Always returns True (indicating this Task should always
+ be executed).
+
+ Subclasses that need this behavior (as opposed to the default
+ of only executing Nodes that are out of date w.r.t. their
+ dependencies) can use this as follows:
+
+ class MyTaskSubclass(SCons.Taskmaster.Task):
+ needs_execute = SCons.Taskmaster.Task.execute_always
+ """
+ return True
+
+class OutOfDateTask(Task):
+ def needs_execute(self):
+ """
+ Returns True (indicating this Task should be executed) if this
+ Task's target state indicates it needs executing, which has
+ already been determined by an earlier up-to-date check.
+ """
+ return self.targets[0].get_state() == SCons.Node.executing
+
def find_cycle(stack, visited):
if stack[-1] in visited:
The Taskmaster for walking the dependency DAG.
"""
- def __init__(self, targets=[], tasker=Task, order=None, trace=None):
+ def __init__(self, targets=[], tasker=None, order=None, trace=None):
self.original_top = targets
self.top_targets_left = targets[:]
self.top_targets_left.reverse()
self.candidates = []
+ if tasker is None:
+ tasker = OutOfDateTask
self.tasker = tasker
if not order:
order = lambda l: l