diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-07-21 20:46:51 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-07-22 18:37:33 +0900 |
commit | 8f8eef574f501b4f9e91580f9c8d866c597bcddd (patch) | |
tree | 431e5f92fb6cc62799f6362b348bdbed3a519b96 | |
parent | bba83174a36d90ec01ea714c4a63c5144c0b8e1e (diff) | |
download | buildstream-8f8eef574f501b4f9e91580f9c8d866c597bcddd.tar.gz |
_variables.pyx, element.py: Lazy variable resolution
Variables are resolved on demand until Variables.check() is explicitly called,
allowing junctions to use variables without requiring that they be completely
resolved.
Approach is courtesy of Valentin David.
-rw-r--r-- | src/buildstream/_variables.pyx | 5 | ||||
-rw-r--r-- | src/buildstream/element.py | 2 |
2 files changed, 2 insertions, 5 deletions
diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx index d1bed3d1c..78f4dcecb 100644 --- a/src/buildstream/_variables.pyx +++ b/src/buildstream/_variables.pyx @@ -139,11 +139,6 @@ cdef class Variables: # self._values = self._init_values(node) - # Resolve all the values, validating for missing - # values and circular references along the way. - # - self.check() - # __getitem__() # # Fetches a resolved variable by it's name, allows diff --git a/src/buildstream/element.py b/src/buildstream/element.py index cd115ca97..547397e54 100644 --- a/src/buildstream/element.py +++ b/src/buildstream/element.py @@ -285,6 +285,8 @@ class Element(Plugin): variables = self.__extract_variables(project, meta) variables["element-name"] = self.name self.__variables = Variables(variables) + if not meta.is_junction: + self.__variables.check() # Collect the composited environment now that we have variables unexpanded_env = self.__extract_environment(project, meta) |