summaryrefslogtreecommitdiff
path: root/buildstream/element.py
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2017-09-12 14:10:07 +0100
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-09-14 14:36:32 -0400
commit032d0f3bbc337663576fdeee70f6a49e66f836c8 (patch)
treea0b9180d2f0c632eb845936e7dc73ec26ebc7406 /buildstream/element.py
parent6a326f465888fbf411682dd6c7c58cc7bc597e6b (diff)
downloadbuildstream-032d0f3bbc337663576fdeee70f6a49e66f836c8.tar.gz
Add support for YAML default config loading
Diffstat (limited to 'buildstream/element.py')
-rw-r--r--buildstream/element.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 9476cf3d6..7029acd7e 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -108,7 +108,7 @@ class Element(Plugin):
any of the dependencies have changed.
"""
- def __init__(self, context, project, artifacts, meta):
+ def __init__(self, context, project, artifacts, meta, plugin_conf):
super().__init__(meta.name, context, project, meta.provenance, "element")
@@ -141,7 +141,7 @@ class Element(Plugin):
self.__splits = None
# Ensure we have loaded this class's defaults
- self.__init_defaults()
+ self.__init_defaults(plugin_conf)
# Collect the composited variables and resolve them
variables = self.__extract_variables(meta)
@@ -1442,22 +1442,16 @@ class Element(Plugin):
element_public['bst'] = element_bst
defaults['public'] = element_public
- def __init_defaults(self):
+ def __init_defaults(self, plugin_conf):
# Defaults are loaded once per class and then reused
#
if not self.__defaults_set:
- # Get the yaml file in the same directory as the plugin
- plugin_file = inspect.getfile(type(self))
- plugin_dir = os.path.dirname(plugin_file)
- plugin_conf_name = "{}.yaml".format(self.get_kind())
- plugin_conf = os.path.join(plugin_dir, plugin_conf_name)
-
# Load the plugin's accompanying .yaml file if one was provided
defaults = {}
try:
- defaults = _yaml.load(plugin_conf, plugin_conf_name)
+ defaults = _yaml.load(plugin_conf, os.path.basename(plugin_conf))
except LoadError as e:
if e.reason != LoadErrorReason.MISSING_FILE:
raise e