summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-02-13 17:07:13 +0000
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-02-14 14:04:45 +0000
commitace15fa6d107db4c9a0cdb5a663fc433f931221f (patch)
tree8705e380bdb42dd96c455b5e8422a45bd9c7b8ff
parent868c057e78e7dfdcbc96a560a06b4f8c532aeedf (diff)
downloadbuildstream-bschubert/dont-keep-metasource.tar.gz
Don't keep MetaSource around in Sourcebschubert/dont-keep-metasource
We can easily rebiuld MetaSource from any source so there is no reason to keep them around. This will slightly improve memory usage.
-rw-r--r--buildstream/source.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index 9e9bad71c..97995a8da 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -168,6 +168,7 @@ from contextlib import contextmanager
from . import Plugin, Consistency
from . import _yaml, utils
from ._exceptions import BstError, ImplError, ErrorDomain
+from ._loader.metasource import MetaSource
from ._projectrefs import ProjectRefStorage
@@ -299,9 +300,6 @@ class Source(Plugin):
self.__expected_alias = None # The primary alias
self.__marked_urls = set() # Set of marked download URLs
- # FIXME: Reconstruct a MetaSource from a Source instead of storing it.
- self.__meta = meta # MetaSource stored so we can copy this source later.
-
# Collect the composited element configuration and
# ask the element to configure itself.
self.__init_defaults(meta)
@@ -984,7 +982,19 @@ class Source(Plugin):
alias = self._get_alias()
source_kind = type(self)
- clone = source_kind(context, project, self.__meta, alias_override=(alias, uri))
+ # Rebuild a MetaSource from the current element
+ meta = MetaSource(
+ self.__element_name,
+ self.__element_index,
+ self.__element_kind,
+ self.get_kind(),
+ self.__config,
+ self.__directory,
+ )
+
+ meta.first_pass = self.__first_pass
+
+ clone = source_kind(context, project, meta, alias_override=(alias, uri))
# Do the necessary post instantiation routines here
#