This is an automated email from the ASF dual-hosted git repository. github-bot pushed a commit to branch valentindavid/flatpak-demo in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit f221dde148cb7db257e6a10f75ac68ca35ea5979 Author: Valentin David <[email protected]> AuthorDate: Wed Jun 27 19:10:37 2018 +0200 Drop BST_PROJECT_INCLUDES_PROCESSED and use kind to detect junctions. --- buildstream/_loader/loader.py | 10 ++-------- buildstream/_project.py | 3 --- buildstream/element.py | 26 ++++++++++---------------- buildstream/plugins/elements/junction.py | 1 - 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py index b6221a2..3637f39 100644 --- a/buildstream/_loader/loader.py +++ b/buildstream/_loader/loader.py @@ -23,7 +23,7 @@ from collections import Mapping, namedtuple import tempfile import shutil -from .._exceptions import LoadError, LoadErrorReason, PluginError +from .._exceptions import LoadError, LoadErrorReason from .. import Consistency from .. import _yaml from ..element import Element @@ -246,13 +246,7 @@ class Loader(): else: raise kind = _yaml.node_get(node, str, Symbol.KIND) - try: - kind_type, _ = self.project.first_pass_config.plugins.get_element_type(kind) - except PluginError: - kind_type = None - if (kind_type and - hasattr(kind_type, 'BST_PROJECT_INCLUDES_PROCESSED') and - not kind_type.BST_PROJECT_INCLUDES_PROCESSED): + if kind == "junction": self._first_pass_options.process_node(node) else: if not self.project.is_loaded(): diff --git a/buildstream/_project.py b/buildstream/_project.py index e50b26a..f58a9c9 100644 --- a/buildstream/_project.py +++ b/buildstream/_project.py @@ -169,9 +169,6 @@ class PluginCollection: self._assert_plugin_format(element, version) return element - def get_element_type(self, kind): - return self._element_factory.lookup(kind) - # create_source() # # Instantiate and return a Source diff --git a/buildstream/element.py b/buildstream/element.py index ae604c5..30665e3 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -191,19 +191,13 @@ class Element(Plugin): *Since: 1.2* """ - BST_PROJECT_INCLUDES_PROCESSED = True - """Whether to load the plugin before processing include directives in - project.conf. - - *Since: 1.2* - - """ - def __init__(self, context, project, artifacts, meta, plugin_conf): super().__init__(meta.name, context, project, meta.provenance, "element") - if not project.is_loaded() and self.BST_PROJECT_INCLUDES_PROCESSED: + self.__is_junction = meta.kind == "junction" + + if not project.is_loaded() and not self.__is_junction: raise ElementError("{}: Cannot load element before project" .format(self), reason="project-not-loaded") @@ -912,7 +906,7 @@ class Element(Plugin): # Instantiate sources for meta_source in meta.sources: - meta_source.first_pass = not element.BST_PROJECT_INCLUDES_PROCESSED + meta_source.first_pass = meta.kind == "junction" source = plugins.create_source(meta_source) redundant_ref = source._load_ref() element.__sources.append(source) @@ -2116,7 +2110,7 @@ class Element(Plugin): element_bst = _yaml.node_get(element_public, Mapping, 'bst', default_value={}) element_splits = _yaml.node_get(element_bst, Mapping, 'split-rules', default_value={}) - if not self.BST_PROJECT_INCLUDES_PROCESSED: + if self.__is_junction: splits = _yaml.node_chain_copy(element_splits) elif project._splits is None: raise LoadError(LoadErrorReason.INVALID_DATA, @@ -2152,7 +2146,7 @@ class Element(Plugin): # Override the element's defaults with element specific # overrides from the project.conf project = self._get_project() - if not self.BST_PROJECT_INCLUDES_PROCESSED: + if self.__is_junction: elements = project.first_pass_config.element_overrides else: elements = project.element_overrides @@ -2171,7 +2165,7 @@ class Element(Plugin): def __extract_environment(self, meta): default_env = _yaml.node_get(self.__defaults, Mapping, 'environment', default_value={}) - if not self.BST_PROJECT_INCLUDES_PROCESSED: + if self.__is_junction: environment = {} else: project = self._get_project() @@ -2189,7 +2183,7 @@ class Element(Plugin): return final_env def __extract_env_nocache(self, meta): - if not self.BST_PROJECT_INCLUDES_PROCESSED: + if self.__is_junction: project_nocache = [] else: project = self._get_project() @@ -2213,7 +2207,7 @@ class Element(Plugin): default_vars = _yaml.node_get(self.__defaults, Mapping, 'variables', default_value={}) project = self._get_project() - if not self.BST_PROJECT_INCLUDES_PROCESSED: + if self.__is_junction: variables = _yaml.node_chain_copy(project.first_pass_config.base_variables) else: assert project.is_loaded() @@ -2242,7 +2236,7 @@ class Element(Plugin): # Sandbox-specific configuration data, to be passed to the sandbox's constructor. # def __extract_sandbox_config(self, meta): - if not self.BST_PROJECT_INCLUDES_PROCESSED: + if self.__is_junction: sandbox_config = {'build-uid': 0, 'build-gid': 0} else: diff --git a/buildstream/plugins/elements/junction.py b/buildstream/plugins/elements/junction.py index dc6e385..ee5ed24 100644 --- a/buildstream/plugins/elements/junction.py +++ b/buildstream/plugins/elements/junction.py @@ -136,7 +136,6 @@ class JunctionElement(Element): # Junctions are not allowed any dependencies BST_FORBID_BDEPENDS = True BST_FORBID_RDEPENDS = True - BST_PROJECT_INCLUDES_PROCESSED = False def configure(self, node): self.path = self.node_get_member(node, str, 'path', default='')
