From 4cc75039a78bd8aef9ef464bc0eb6c3ff16809d0 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 29 Apr 2015 20:42:21 +0000 Subject: SourceResolver: Allow the resolution of multiple systems The existing Source resolution code handles resolution of multiple systems sufficiently. It is not appropriate to then take this source pool and attempt to create a build graph from it though, as the logical structure of the input of what we want to build, and the logical structure of what we will produce are conflated in the Source object. If we do not intend to create a build graph from the Source Pool we generate, then it is an appropriate data structure that may be used to analyse changes in the input to a build. Change-Id: If8e4a726f16f8aca000e59ecbbeb7d926cc08391 --- morphlib/buildcommand.py | 9 ++++++--- morphlib/sourceresolver.py | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py index efd10f26..6a5373ab 100644 --- a/morphlib/buildcommand.py +++ b/morphlib/buildcommand.py @@ -84,7 +84,8 @@ class BuildCommand(object): return morphlib.buildenvironment.BuildEnvironment(self.app.settings, arch) - def create_source_pool(self, repo_name, ref, filename, original_ref=None): + def create_source_pool(self, repo_name, ref, filename=None, + original_ref=None, filenames=None): '''Find the source objects required for building a the given artifact The SourcePool will contain every stratum and chunk dependency of the @@ -93,12 +94,14 @@ class BuildCommand(object): ''' self.app.status(msg='Creating source pool', chatty=True) + if filenames is None and filename is not None: + filenames = (filename,) srcpool = morphlib.sourceresolver.create_source_pool( - self.lrc, self.rrc, repo_name, ref, filename, + self.lrc, self.rrc, repo_name, ref, filename=None, cachedir=self.app.settings['cachedir'], original_ref=original_ref, update_repos=not self.app.settings['no-git-update'], - status_cb=self.app.status) + status_cb=self.app.status, filenames=filenames) return srcpool def validate_sources(self, srcpool): diff --git a/morphlib/sourceresolver.py b/morphlib/sourceresolver.py index e338dd4d..b8907bfe 100644 --- a/morphlib/sourceresolver.py +++ b/morphlib/sourceresolver.py @@ -600,7 +600,7 @@ class SourceResolver(object): def create_source_pool(lrc, rrc, repo, ref, filename, cachedir, original_ref=None, update_repos=True, - status_cb=None): # pragma: no cover + status_cb=None, filenames=None): # pragma: no cover '''Find all the sources involved in building a given system. Given a system morphology, this function will traverse the tree of stratum @@ -616,6 +616,8 @@ def create_source_pool(lrc, rrc, repo, ref, filename, cachedir, ''' pool = morphlib.sourcepool.SourcePool() + if filenames is None and filenames is not None: + filenames = (filename,) def add_to_pool(reponame, ref, filename, absref, tree, morphology): sources = morphlib.source.make_sources(reponame, ref, @@ -634,7 +636,7 @@ def create_source_pool(lrc, rrc, repo, ref, filename, cachedir, resolver = SourceResolver(lrc, rrc, tree_cache_manager, buildsystem_cache_manager, update_repos, status_cb) - resolver.traverse_morphs(repo, ref, [filename], + resolver.traverse_morphs(repo, ref, filenames, visit=add_to_pool, definitions_original_ref=original_ref) return pool -- cgit v1.2.1