summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-05-16 08:25:53 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2019-05-17 17:17:55 +0100
commit270ee6ea9673269b2e8edd2b02d29319b2c416a0 (patch)
tree122652a1041752e3c0b58e6571c967761fbd66d1
parent1dad46a5800adf2a6c9ef3c6589365cee03fd8f4 (diff)
downloadbuildstream-270ee6ea9673269b2e8edd2b02d29319b2c416a0.tar.gz
element.py: Make public data extraction classy
To clarify data flow, make the extraction of public data into a classmethod, and add an expand method to deal with the instance variable expansion. Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
-rw-r--r--buildstream/element.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 72779915b..08eb5db16 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -258,7 +258,8 @@ class Element(Plugin):
self.__env_nocache = nocache
# Grab public domain data declared for this instance
- self.__public = self.__extract_public(meta)
+ unexpanded_public = self.__extract_public(meta)
+ self.__public = self.__expand_splits(unexpanded_public)
self.__dynamic_public = None
# Collect the composited element configuration and
@@ -2605,8 +2606,9 @@ class Element(Plugin):
# This makes a special exception for the split rules, which
# elements may extend but whos defaults are defined in the project.
#
- def __extract_public(self, meta):
- base_public = _yaml.node_get(self.__defaults, Mapping, 'public', default_value={})
+ @classmethod
+ def __extract_public(cls, meta):
+ base_public = _yaml.node_get(cls.__defaults, Mapping, 'public', default_value={})
base_public = _yaml.node_copy(base_public)
base_bst = _yaml.node_get(base_public, Mapping, 'bst', default_value={})
@@ -2625,13 +2627,20 @@ class Element(Plugin):
_yaml.node_final_assertions(element_public)
- # Also, resolve any variables in the public split rules directly
- for domain, splits in self.node_items(base_splits):
+ return element_public
+
+ # Expand the splits in the public data using the Variables in the element
+ def __expand_splits(self, element_public):
+ element_bst = _yaml.node_get(element_public, Mapping, 'bst', default_value={})
+ element_splits = _yaml.node_get(element_bst, Mapping, 'split-rules', default_value={})
+
+ # Resolve any variables in the public split rules directly
+ for domain, splits in self.node_items(element_splits):
splits = [
self.__variables.subst(split.strip())
for split in splits
]
- _yaml.node_set(base_splits, domain, splits)
+ _yaml.node_set(element_splits, domain, splits)
return element_public