From cf1a2d326af47e0cdf49cd99d1e4447f494de231 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Fri, 27 Oct 2017 21:18:15 +0900 Subject: context.py: Moving strict mode configuration to be project specific --- buildstream/context.py | 30 ++++++++++++++++++++++-------- buildstream/data/userconfig.yaml | 19 ------------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/buildstream/context.py b/buildstream/context.py index 68498e1dd..fb2e074a2 100644 --- a/buildstream/context.py +++ b/buildstream/context.py @@ -59,7 +59,7 @@ class Context(): self.target_arch = target_arch or host_arch """The machine on which the results of the build should execute""" - self.strict_build_plan = True + self.strict_build_plan = None """Whether elements must be rebuilt when their dependencies have changed""" self.sourcedir = None @@ -161,15 +161,10 @@ class Context(): _yaml.composite(defaults, user_config) _yaml.node_validate(defaults, [ - 'strict', 'sourcedir', - 'builddir', 'artifactdir', - 'logdir', 'scheduler', - 'artifacts', 'logging', - 'projects', + 'sourcedir', 'builddir', 'artifactdir', 'logdir', + 'scheduler', 'artifacts', 'logging', 'projects', ]) - self.strict_build_plan = _yaml.node_get(defaults, bool, 'strict') - for dir in ['sourcedir', 'builddir', 'artifactdir', 'logdir']: # Allow the ~ tilde expansion and any environment variables in # path specification in the config files. @@ -248,6 +243,25 @@ class Context(): def _get_overrides(self, project_name): return _yaml.node_get(self._project_overrides, Mapping, project_name, default_value={}) + # _get_strict(): + # + # Fetch whether we are strict or not + # + # Args: + # project_name (str): The project name + # + # Returns: + # (bool): Whether or not to use strict build plan + # + def _get_strict(self, project_name): + + # If it was set by the CLI, it overrides any config + if self.strict_build_plan is not None: + return self.strict_build_plan + + overrides = self._get_overrides(project_name) + return _yaml.node_get(overrides, bool, 'strict', default_value=True) + # _get_cache_key(): # # Returns the cache key, calculating it if necessary diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml index 1ab4139fc..8d066ab52 100644 --- a/buildstream/data/userconfig.yaml +++ b/buildstream/data/userconfig.yaml @@ -10,9 +10,6 @@ # paths. # -# Whether elements must be rebuilt when their dependencies have changed -strict: True - # Location to store sources sourcedir: ${XDG_CACHE_HOME}/buildstream/sources @@ -97,19 +94,3 @@ logging: %{state: >12} %{key} %{name} %{workspace-dirs} -# -# Per project overrides -# -# Some settings defined in the project configuration can be overridden by -# the user configuration. -# -# projects: -# -# project1: -# artifacts: -# pull-url: https://artifacts.com -# push-url: artifacts@artifacts.com:artifacts -# push-port: 443 -# -# project2: -# ... -- cgit v1.2.1