summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Taskmaster.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2001-10-05 17:37:48 (GMT)
committerSteven Knight <knight@baldmt.com>2001-10-05 17:37:48 (GMT)
commita86827b3933c2861d2e5b9df319630ce04559fe0 (patch)
tree4172953c924c5d23c8b1622fd0d9d5e980f79cc3 /src/engine/SCons/Taskmaster.py
parenta0e380faef8af1b62213a0ea1840b38fa0ecf6e4 (diff)
downloadSCons-a86827b3933c2861d2e5b9df319630ce04559fe0.zip
SCons-a86827b3933c2861d2e5b9df319630ce04559fe0.tar.gz
SCons-a86827b3933c2861d2e5b9df319630ce04559fe0.tar.bz2
Use the Node Walker to build dependencies in order.
Diffstat (limited to 'src/engine/SCons/Taskmaster.py')
-rw-r--r--src/engine/SCons/Taskmaster.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py
new file mode 100644
index 0000000..651769d
--- /dev/null
+++ b/src/engine/SCons/Taskmaster.py
@@ -0,0 +1,106 @@
+"""SCons.Taskmaster
+
+Generic Taskmaster.
+
+"""
+
+#
+# Copyright (c) 2001 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+
+
+
+import SCons.Node
+
+
+
+class Task:
+ """Default SCons build engine task."""
+ def __init__(self,target):
+ self.target = target
+
+ def execute(self):
+ self.target.build()
+
+
+
+def current(node):
+ """Default SCons build engine is-it-current function.
+
+ This returns "always out of date," so every node is always
+ built/visited.
+ """
+ return None
+
+
+
+class Taskmaster:
+ """A generic Taskmaster for handling a bunch of targets.
+ """
+
+ def __init__(self, targets=[], tasker=Task, current=current):
+ self.targets = targets
+ self.tasker = tasker
+ self.current = current
+ self.num_iterated = 0
+ self.walker = None
+
+ def next_node(self):
+ t = None
+ if self.walker:
+ t = self.walker.next()
+ if t == None and self.num_iterated < len(self.targets):
+ t = self.targets[self.num_iterated]
+ self.num_iterated = self.num_iterated + 1
+ t.top_target = 1
+ self.walker = SCons.Node.Walker(t)
+ t = self.walker.next()
+ top = None
+ if hasattr(t, "top_target"):
+ top = 1
+ return t, top
+
+ def next_task(self):
+ n, top = self.next_node()
+ while n != None:
+ if self.current(n):
+ self.up_to_date(n)
+ else:
+ return self.tasker(n)
+ n, top = self.next_node()
+ return None
+
+ def is_blocked(self):
+ return 0
+
+ def up_to_date(self, node):
+ pass
+
+ def executed(self, task):
+ pass
+
+ def failed(self, task):
+ self.walker = None
+ self.num_iterated = len(self.targets)