summaryrefslogtreecommitdiff
path: root/buildstream/source.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildstream/source.py')
-rw-r--r--buildstream/source.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index ec38ae8f2..77f2a05ef 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -137,8 +137,9 @@ class Source(Plugin):
# Collect the composited element configuration and
# ask the element to configure itself.
- self.__init_defaults()
+ self.__init_defaults(meta)
self.__config = self.__extract_config(meta)
+
self.configure(self.__config)
COMMON_CONFIG_KEYS = ['kind', 'directory']
@@ -557,24 +558,29 @@ class Source(Plugin):
#
# Step 3 - Apply the change in project data
#
- if project is toplevel:
- if toplevel.ref_storage == ProjectRefStorage.PROJECT_REFS:
- do_save_refs(toplevel_refs)
- else:
+ if toplevel.ref_storage == ProjectRefStorage.PROJECT_REFS:
+ do_save_refs(toplevel_refs)
+ else:
+ if provenance.filename.project is toplevel:
# Save the ref in the originating file
#
- fullname = os.path.join(toplevel.element_path, provenance.filename)
try:
- _yaml.dump(provenance.toplevel, fullname)
+ _yaml.dump(_yaml.node_sanitize(provenance.toplevel), provenance.filename.name)
except OSError as e:
raise SourceError("{}: Error saving source reference to '{}': {}"
- .format(self, provenance.filename, e),
+ .format(self, provenance.filename.name, e),
reason="save-ref-error") from e
- else:
- if toplevel.ref_storage == ProjectRefStorage.PROJECT_REFS:
- do_save_refs(toplevel_refs)
- else:
+ elif provenance.filename.project is project:
self.warn("{}: Not persisting new reference in junctioned project".format(self))
+ elif provenance.filename.project is None:
+ assert provenance.filename.name == ''
+ assert provenance.filename.shortname == ''
+ raise SourceError("{}: Error saving source reference to synthetic node."
+ .format(self))
+ else:
+ raise SourceError("{}: Cannot track source in a fragment from a junction"
+ .format(provenance.filename.shortname),
+ reason="tracking-junction-fragment")
return changed
@@ -611,10 +617,13 @@ class Source(Plugin):
reason="ensure-stage-dir-fail") from e
return directory
- def __init_defaults(self):
+ def __init_defaults(self, meta):
if not self.__defaults_set:
project = self._get_project()
- sources = project.source_overrides
+ if meta.first_pass:
+ sources = project.first_pass_config.source_overrides
+ else:
+ sources = project.source_overrides
type(self).__defaults = sources.get(self.get_kind(), {})
type(self).__defaults_set = True