diff options
-rw-r--r-- | buildstream/_frontend/cli.py | 12 | ||||
-rw-r--r-- | buildstream/_pipeline.py | 43 |
2 files changed, 41 insertions, 14 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index 3d50d5c14..213c4ed1e 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -277,7 +277,7 @@ def fetch(app, elements, deps, track_, except_, track_cross_junctions): track_elements=elements if track_ else None, track_cross_junctions=track_cross_junctions, fetch_subprojects=True): - dependencies = app.pipeline.deps_elements(deps) + dependencies = app.pipeline.get_selection(deps) app.pipeline.fetch(app.scheduler, dependencies) @@ -313,7 +313,7 @@ def track(app, elements, deps, except_, cross_junctions): track_elements=elements, track_cross_junctions=cross_junctions, fetch_subprojects=True): - dependencies = app.pipeline.deps_elements(deps) + dependencies = app.pipeline.get_selection(deps) app.pipeline.track(app.scheduler) @@ -344,7 +344,7 @@ def pull(app, elements, deps, remote): """ with app.initialized(elements, session_name="Pull", use_configured_remote_caches=(remote is None), add_remote_cache=remote, fetch_subprojects=True): - to_pull = app.pipeline.deps_elements(deps) + to_pull = app.pipeline.get_selection(deps) app.pipeline.pull(app.scheduler, to_pull) @@ -375,7 +375,7 @@ def push(app, elements, deps, remote): with app.initialized(elements, session_name="Push", use_configured_remote_caches=(remote is None), add_remote_cache=remote, fetch_subprojects=True): - to_push = app.pipeline.deps_elements(deps) + to_push = app.pipeline.get_selection(deps) app.pipeline.push(app.scheduler, to_push) @@ -449,7 +449,7 @@ def show(app, elements, deps, except_, order, format_, downloadable): """ with app.initialized(elements, except_=except_, use_configured_remote_caches=downloadable): - dependencies = app.pipeline.deps_elements(deps) + dependencies = app.pipeline.get_selection(deps) if order == "alpha": dependencies = sorted(dependencies) @@ -582,7 +582,7 @@ def source_bundle(app, target, force, directory, """Produce a source bundle to be manually executed """ with app.initialized((target,), rewritable=track_, track_elements=[target] if track_ else None): - dependencies = app.pipeline.deps_elements('all') + dependencies = app.pipeline.get_selection('all') app.pipeline.source_bundle(app.scheduler, dependencies, force, track_, compression, directory) diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index e4e8377c2..540d0715f 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -42,6 +42,33 @@ from ._artifactcache.artifactcache import ArtifactCacheSpec, configured_remote_a from ._scheduler import SchedStatus, TrackQueue, FetchQueue, BuildQueue, PullQueue, PushQueue +# PipelineSelection() +# +# Defines the kind of pipeline selection to make when the pipeline +# is provided a list of targets, for whichever purpose. +# +# These values correspond to the CLI `--deps` arguments for convenience. +# +class PipelineSelection(): + + # Select only the target elements in the associated targets + NONE = 'none' + + # Select elements which must be built for the associated targets to be built + PLAN = 'plan' + + # All dependencies of all targets, including the targets + ALL = 'all' + + # All direct build dependencies and their recursive runtime dependencies, + # excluding the targets + BUILD = 'build' + + # All direct runtime dependencies and their recursive runtime dependencies, + # including the targets + RUN = 'run' + + # Pipeline() # # Args: @@ -176,28 +203,28 @@ class Pipeline(): # Reset the element loader state Element._reset_load_state() - # deps_elements() + # get_selection() # # Args: - # mode (str): A specific mode of resolving deps + # mode (PipelineSelection): The PipelineSelection mode # # Various commands define a --deps option to specify what elements to # use in the result, this function reports a list that is appropriate for # the selected option. # - def deps_elements(self, mode): + def get_selection(self, mode): elements = None - if mode == 'none': + if mode == PipelineSelection.NONE: elements = self.targets - elif mode == 'plan': + elif mode == PipelineSelection.PLAN: elements = list(self._plan()) else: - if mode == 'all': + if mode == PipelineSelection.ALL: scope = Scope.ALL - elif mode == 'build': + elif mode == PipelineSelection.BUILD: scope = Scope.BUILD - elif mode == 'run': + elif mode == PipelineSelection.RUN: scope = Scope.RUN elements = list(self.dependencies(scope)) |