summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-06-27 19:10:37 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-07-02 16:24:53 +0200
commitf221dde148cb7db257e6a10f75ac68ca35ea5979 (patch)
treefe93f01b6d1ba2a9b014851b6d9b7fd1d7a06284
parentda42c7d4a4922b3ea41e969aa3c25b1f331b25be (diff)
downloadbuildstream-f221dde148cb7db257e6a10f75ac68ca35ea5979.tar.gz
Drop BST_PROJECT_INCLUDES_PROCESSED and use kind to detect junctions.
-rw-r--r--buildstream/_loader/loader.py10
-rw-r--r--buildstream/_project.py3
-rw-r--r--buildstream/element.py26
-rw-r--r--buildstream/plugins/elements/junction.py1
4 files changed, 12 insertions, 28 deletions
diff --git a/buildstream/_loader/loader.py b/buildstream/_loader/loader.py
index b6221a29a..3637f39a6 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 e50b26a33..f58a9c91a 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 ae604c575..30665e35f 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 dc6e385a9..ee5ed24d5 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='')