summaryrefslogtreecommitdiff
path: root/morphlib/builder.py
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-31 16:38:18 +0000
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-01-31 16:42:41 +0000
commitc2104eb199916f9ef7e7b77d0eebf33619ed3ea9 (patch)
tree01eb904eda1461bf70ecf97aa8f6445d0bbfbb07 /morphlib/builder.py
parentab965be42d10f2608dc883ee0cc34a1cd0fe5058 (diff)
downloadmorph-c2104eb199916f9ef7e7b77d0eebf33619ed3ea9.tar.gz
Properly unpack dependencies into the staging area in build-single.
This requires build-single to take a dependency context tuple when building chunks of a stratum. This context tuple is the surrounding stratum which is used to construct the dependency graph in the worker and then do a breadth-first search to collect all dependencies that need to be added to the staging area. Implementing this required a few hash/eq changes in Blob, Morphology and Treeish as well as a few adjustments in the corresponding unit tests.
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r--morphlib/builder.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py
index 53127223..9d7e066d 100644
--- a/morphlib/builder.py
+++ b/morphlib/builder.py
@@ -14,6 +14,7 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+import collections
import json
import logging
import os
@@ -564,31 +565,33 @@ class Builder(object):
# first pass: create builders for all blobs
builders = {}
for group in build_order:
- for blob in group:
- builder = self.create_blob_builder(blob)
- builders[blob] = builder
-
- # second pass: walk the build order blob by blob, mark blobs
- # to be staged for their parents, but do not build them
- ret = []
- for group in build_order:
- for blob in group:
- built_items = builders[blob].builds()
- for parent in blob.parents:
- stage_items = []
- for name, filename in built_items.items():
- self.msg('Marking %s to be staged for %s' %
- (name, parent))
- stage_items.append((name, filename))
-
- parent_builder = builders[parent]
- parent_builder.stage_items.extend(stage_items)
+ for b in group:
+ builder = self.create_blob_builder(b)
+ builders[b] = builder
+
+ # second pass: mark all dependencies for staging
+ queue = collections.deque()
+ visited = set()
+ for dependency in blob.dependencies:
+ queue.append(dependency)
+ visited.add(dependency)
+ while len(queue) > 0:
+ dependency = queue.popleft()
+ built_items = builders[dependency].builds()
+ for name, filename in built_items.items():
+ self.msg('Marking %s to be staged for %s' % (name, blob))
+ builders[blob].stage_items.append((name, filename))
+ for dep in dependency.dependencies:
+ if (dependency.morph.kind == 'stratum' and
+ not dep.morph.kind == 'chunk'):
+ if dep not in visited:
+ queue.append(dep)
+ visited.add(dep)
# build the single blob now
+ ret = []
ret.append(builders[blob].build())
-
self.indent_less()
-
return ret
def create_blob_builder(self, blob):