summaryrefslogtreecommitdiff
path: root/src/buildstream/_context.py
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2019-12-31 16:15:09 +0000
committerTristan Maat <tm@tlater.net>2020-01-08 17:22:54 +0000
commit3c1936ab225cce954428a962effbf47c8f43728c (patch)
tree7047359ca54ae4ea189a2e715daef8ce553cabdb /src/buildstream/_context.py
parent2855243b80e6b549e338f438b89a6867cfd7ff45 (diff)
downloadbuildstream-3c1936ab225cce954428a962effbf47c8f43728c.tar.gz
Make PipelineSelection a proper enum type
PipelineSelection is one of the few stringy types that weren't converted to FastEnum, presumably because we lacked a mechanism for only allowing a sub-set of options as CLI arguments. We've re-designed this since, and as part of the UI/UX refactor we'd like to generally clean this, but that is probably still a while out. Since that hasn't happened, for now, this adds a feature to the FastEnumType that allows specifying only a subset of values is allowed for a specific command, so that we can use the type as a proper enum. We also get rid of a number of accidental uses of strings, and move PipelineSelection to buildstream.types so that we don't have a significant import overhead for it.
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r--src/buildstream/_context.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 47001440a..9642edd49 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -29,7 +29,7 @@ from ._platform import Platform
from ._artifactcache import ArtifactCache
from ._sourcecache import SourceCache
from ._cas import CASCache, CASLogLevel
-from .types import _CacheBuildTrees, _SchedulerErrorAction
+from .types import _CacheBuildTrees, _PipelineSelection, _SchedulerErrorAction
from ._workspaces import Workspaces, WorkspaceProjectCache
from .node import Node
from .sandbox import SandboxRemote
@@ -361,13 +361,14 @@ class Context:
build.validate_keys(["max-jobs", "dependencies"])
self.build_max_jobs = build.get_int("max-jobs")
- self.build_dependencies = build.get_str("dependencies")
- if self.build_dependencies not in ["plan", "all"]:
+ dependencies = build.get_str("dependencies")
+ if dependencies not in ["plan", "all"]:
provenance = build.get_scalar("dependencies").get_provenance()
raise LoadError(
"{}: Invalid value for 'dependencies'. Choose 'plan' or 'all'.".format(provenance),
LoadErrorReason.INVALID_DATA,
)
+ self.build_dependencies = _PipelineSelection(dependencies)
# Load per-projects overrides
self._project_overrides = defaults.get_mapping("projects", default={})