diff options
author | Jürg Billeter <j@bitron.ch> | 2017-10-23 11:17:21 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2018-02-08 14:04:04 +0100 |
commit | 1d331b9b7db812e3f18c3eed33af92739c2ffb7b (patch) | |
tree | d40c49423bb7aa804f0993495330c632d46fa9ba /buildstream | |
parent | b5f101a2ac19ff4e64de17a18230e351137c1884 (diff) | |
download | buildstream-1d331b9b7db812e3f18c3eed33af92739c2ffb7b.tar.gz |
Move cli_options from Context to Project
cli_options are project-specific.
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_context.py | 3 | ||||
-rw-r--r-- | buildstream/_frontend/main.py | 8 | ||||
-rw-r--r-- | buildstream/_project.py | 6 |
3 files changed, 9 insertions, 8 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py index b86ce2ad1..317621f0a 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -45,7 +45,7 @@ from ._artifactcache import artifact_cache_specs_from_config_node # class Context(): - def __init__(self, cli_options): + def __init__(self): # Filename indicating which configuration file was used, or None for the defaults self.config_origin = None @@ -110,7 +110,6 @@ class Context(): self._message_depth = deque() self._platform = None self._project_overrides = {} - self._cli_options = cli_options # load() # diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index 1abbd3592..cc92e6412 100644 --- a/buildstream/_frontend/main.py +++ b/buildstream/_frontend/main.py @@ -704,14 +704,14 @@ def workspace_list(app): config = app.main_options['config'] try: - context = Context(app.main_options['option']) + context = Context() context.load(config) except BstError as e: click.echo("Error loading user configuration: {}".format(e), err=True) sys.exit(-1) try: - project = Project(directory, context) + project = Project(directory, context, cli_options=app.main_options['option']) except BstError as e: click.echo("Error loading project: {}".format(e), err=True) sys.exit(-1) @@ -800,7 +800,7 @@ class App(): config = self.main_options['config'] try: - self.context = Context(self.main_options['option']) + self.context = Context() self.context.load(config) except BstError as e: click.echo("Error loading user configuration: {}".format(e), err=True) @@ -859,7 +859,7 @@ class App(): self.context._set_message_handler(self.message_handler) try: - self.project = Project(directory, self.context) + self.project = Project(directory, self.context, cli_options=self.main_options['option']) except BstError as e: click.echo("Error loading project: {}".format(e), err=True) sys.exit(-1) diff --git a/buildstream/_project.py b/buildstream/_project.py index 92efce926..d44a891bd 100644 --- a/buildstream/_project.py +++ b/buildstream/_project.py @@ -57,7 +57,7 @@ _ALIAS_SEPARATOR = ':' # class Project(): - def __init__(self, directory, context): + def __init__(self, directory, context, *, cli_options=None): # The project name self.name = None @@ -77,6 +77,7 @@ class Project(): self._plugin_source_origins = [] # Origins of custom sources self._plugin_element_origins = [] # Origins of custom elements self._options = None # Project options, the OptionPool + self._cli_options = cli_options self._cache_key = None self._source_format_versions = {} self._element_format_versions = {} @@ -157,7 +158,8 @@ class Project(): overrides = self._context._get_overrides(self.name) override_options = _yaml.node_get(overrides, Mapping, 'options', default_value={}) self._options.load_yaml_values(override_options) - self._options.load_cli_values(self._context._cli_options) + if self._cli_options: + self._options.load_cli_values(self._cli_options) # We're done modifying options, now we can use them for substitutions self._options.resolve() |