diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-24 13:33:56 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-24 13:33:56 +0000 |
commit | 238b1a44bda17ce49f424c4d874e0dd74c29c5c8 (patch) | |
tree | 0858a09e7ea58c19ae9e995348cffb8b63155d2b /morphlib | |
parent | 87aa2c5a7c1f2cb0ca74959d5a082ccc80f6502a (diff) | |
parent | e335d4f25ff93ca3fba4c96d54131bbe1f646d3b (diff) | |
download | morph-238b1a44bda17ce49f424c4d874e0dd74c29c5c8.tar.gz |
Merge remote-tracking branch 'origin/master' into rm/timings-back
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/builder2.py | 22 | ||||
-rw-r--r-- | morphlib/builder2_tests.py | 5 |
2 files changed, 20 insertions, 7 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() diff --git a/morphlib/builder2_tests.py b/morphlib/builder2_tests.py index e3f81d16..67379341 100644 --- a/morphlib/builder2_tests.py +++ b/morphlib/builder2_tests.py @@ -134,11 +134,13 @@ class BuilderBaseTests(unittest.TestCase): self.staging_area = FakeStagingArea(self.fake_runcmd) self.artifact_cache = FakeArtifactCache() self.artifact = FakeArtifact('le-artifact') + self.repo_cache = None self.build_env = FakeBuildEnv() self.max_jobs = 1 self.builder = morphlib.builder2.BuilderBase(self.staging_area, self.artifact_cache, self.artifact, + self.repo_cache, self.build_env, self.max_jobs) @@ -202,7 +204,8 @@ class BuilderBaseTests(unittest.TestCase): class ChunkBuilderTests(unittest.TestCase): def setUp(self): - self.build = morphlib.builder2.ChunkBuilder(None, None, None, None, 1) + self.build = morphlib.builder2.ChunkBuilder(None, None, None, None, + None, 1) def test_uses_morphology_commands_when_given(self): m = { 'build-commands': ['build-it'] } |