diff options
| author | Steven Knight <knight@baldmt.com> | 2008-12-08 19:04:22 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2008-12-08 19:04:22 (GMT) |
| commit | 665765284f5de349b469c77fa384fb16ee56c4ce (patch) | |
| tree | 28afa41b1d9533900eba93984e9687d0ab51b8a3 /src/engine/SCons/Taskmaster.py | |
| parent | 9c0324beafa6dd9f4554b25d6824ea2f5de7cb77 (diff) | |
| download | SCons-665765284f5de349b469c77fa384fb16ee56c4ce.zip SCons-665765284f5de349b469c77fa384fb16ee56c4ce.tar.gz SCons-665765284f5de349b469c77fa384fb16ee56c4ce.tar.bz2 | |
Create Taskmaster.{Always,OutOfDate}Task subclasses of Taskmaster.Task
to hold different implementations of the .needs_execute() method.
Diffstat (limited to 'src/engine/SCons/Taskmaster.py')
| -rw-r--r-- | src/engine/SCons/Taskmaster.py | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index eefe56b..f360402 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -197,14 +197,11 @@ class Task: 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): @@ -501,6 +498,30 @@ class Task: 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: @@ -521,11 +542,13 @@ class Taskmaster: 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 |
