diff options
author | Benjamin Schubert <contact@benschubert.me> | 2020-05-12 12:13:05 +0000 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2020-05-12 15:52:00 +0000 |
commit | 830e2142ff9f2688c04119df5be8efebc2649dca (patch) | |
tree | 9ffca9cc20d5f5651f6486553637e6d89b47bf4b /src/buildstream/source.py | |
parent | 1ff22fb98d58f1264a2af0650e40dcaaaa99dabc (diff) | |
download | buildstream-830e2142ff9f2688c04119df5be8efebc2649dca.tar.gz |
source.py: Allow access to element's variable
This automatically expands the variables from the element into
the sources config
Diffstat (limited to 'src/buildstream/source.py')
-rw-r--r-- | src/buildstream/source.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/buildstream/source.py b/src/buildstream/source.py index 7b790cdbb..049db7062 100644 --- a/src/buildstream/source.py +++ b/src/buildstream/source.py @@ -173,6 +173,7 @@ from ._cachekey import generate_key from .storage import CasBasedDirectory from .storage import FileBasedDirectory from .storage.directory import Directory, VirtualDirectoryError +from ._variables import Variables if TYPE_CHECKING: from typing import Any, Dict, Set @@ -321,6 +322,7 @@ class Source(Plugin): context: "Context", project: "Project", meta: MetaSource, + variables: Variables, *, alias_override: Optional[Tuple[str, str]] = None, unique_id: Optional[int] = None @@ -341,6 +343,7 @@ class Source(Plugin): self.__element_kind = meta.element_kind # The kind of the element owning this source self.__directory = meta.directory # Staging relative directory self.__meta_kind = meta.kind # The kind of this source, required for unpickling + self.__variables = variables # The variables used to resolve the source's config self.__key = None # Cache key for source @@ -354,6 +357,8 @@ class Source(Plugin): # ask the element to configure itself. self.__init_defaults(project, meta) self.__config = self.__extract_config(meta) + variables.expand(self.__config) + self.__first_pass = meta.first_pass # cached values for commonly access values on the source @@ -1238,7 +1243,9 @@ class Source(Plugin): meta.first_pass = self.__first_pass - clone = source_kind(context, project, meta, alias_override=(alias, uri), unique_id=self._unique_id) + clone = source_kind( + context, project, meta, self.__variables, alias_override=(alias, uri), unique_id=self._unique_id + ) # Do the necessary post instantiation routines here # |