summaryrefslogtreecommitdiff
path: root/morphlib/builder2.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-04-24 13:33:56 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-04-24 13:33:56 +0000
commit238b1a44bda17ce49f424c4d874e0dd74c29c5c8 (patch)
tree0858a09e7ea58c19ae9e995348cffb8b63155d2b /morphlib/builder2.py
parent87aa2c5a7c1f2cb0ca74959d5a082ccc80f6502a (diff)
parente335d4f25ff93ca3fba4c96d54131bbe1f646d3b (diff)
downloadmorph-238b1a44bda17ce49f424c4d874e0dd74c29c5c8.tar.gz
Merge remote-tracking branch 'origin/master' into rm/timings-back
Diffstat (limited to 'morphlib/builder2.py')
-rw-r--r--morphlib/builder2.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py
index 6da07c1f..9a79dea4 100644
--- a/morphlib/builder2.py
+++ b/morphlib/builder2.py
@@ -26,11 +26,12 @@ class BuilderBase(object):
'''Base class for building artifacts.'''
- def __init__(self, staging_area, artifact_cache, artifact, build_env,
- max_jobs):
+ def __init__(self, staging_area, artifact_cache, artifact, repo_cache,
+ build_env, max_jobs):
self.staging_area = staging_area
self.artifact_cache = artifact_cache
self.artifact = artifact
+ self.repo_cache = repo_cache
self.build_env = build_env
self.max_jobs = max_jobs
self.build_watch = morphlib.stopwatch.Stopwatch()
@@ -141,6 +142,8 @@ class ChunkBuilder(BuilderBase):
def get_sources(self, srcdir): # pragma: no cover
'''Get sources from git to a source directory, for building.'''
+ cache_dir = os.path.dirname(self.artifact.source.repo.path)
+
def extract_repo(path, sha1, destdir):
logging.debug('Extracting %s into %s' % (path, destdir))
if not os.path.exists(destdir):
@@ -154,8 +157,12 @@ class ChunkBuilder(BuilderBase):
except morphlib.git.NoModulesFileError:
return []
else:
- return [(sub.path, sub.commit, os.path.join(destdir, sub.path))
- for sub in submodules]
+ tuples = []
+ for sub in submodules:
+ cached_repo = self.repo_cache.get_repo(sub.url)
+ sub_dir = os.path.join(destdir, sub.path)
+ tuples.append((cached_repo.path, sub.commit, sub_dir))
+ return tuples
s = self.artifact.source
todo = [(s.repo.path, s.sha1, srcdir)]
@@ -432,16 +439,19 @@ class Builder(object): # pragma: no cover
'system': SystemBuilder,
}
- def __init__(self, staging_area, artifact_cache, build_env, max_jobs):
+ def __init__(self, staging_area, artifact_cache, repo_cache, build_env,
+ max_jobs):
self.staging_area = staging_area
self.artifact_cache = artifact_cache
+ self.repo_cache = repo_cache
self.build_env = build_env
self.max_jobs = max_jobs
def build_and_cache(self, artifact):
kind = artifact.source.morphology['kind']
o = self.classes[kind](self.staging_area, self.artifact_cache,
- artifact, self.build_env, self.max_jobs)
+ artifact, self.repo_cache, self.build_env,
+ self.max_jobs)
logging.debug('Builder.build: artifact %s with %s' %
(artifact.name, repr(o)))
o.build_and_cache()