diff options
Diffstat (limited to 'src/buildstream/_project.py')
-rw-r--r-- | src/buildstream/_project.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py index fcfb31988..3a8998abb 100644 --- a/src/buildstream/_project.py +++ b/src/buildstream/_project.py @@ -158,6 +158,11 @@ class Project: self._sandbox = None self._splits = None + # This is a lookup table of dictionaries indexed by project, + # the child dictionaries are junction names as keys with their + # provenances as values + self._junction_duplicates = {} + self._context.add_project(self) self._partially_loaded = False @@ -434,6 +439,12 @@ class Project: Element._clear_meta_elements_cache() + # Assert loaders after resolving everything, this is because plugin + # loading (across junction boundaries) can also be the cause of + # conflicting projects. + # + self.load_context.assert_loaders() + # Now warn about any redundant source references which may have # been discovered in the resolve() phase. redundant_refs = Element._get_redundant_source_refs() @@ -541,6 +552,37 @@ class Project: return tuple(default_targets) + # junction_is_duplicated() + # + # Check whether this loader is specified as a duplicate by + # this project. + # + # Args: + # project_name: (str): The project name + # loader (Loader): The loader to check for + # + # Returns: + # (bool): Whether the loader is specified as duplicate + # + def junction_is_duplicated(self, project_name, loader): + + junction_dict = self._junction_duplicates.get(project_name, {}) + + # Iterate over all paths specified by this project and see + # if we find a match for the specified loader. + # + # Using the regular `Loader.get_loader()` codepath from this + # project ensures that we will find the correct loader relative + # to this project, regardless of any overrides or link elements + # which might have been used in the project. + # + for dup_path, dup_provenance in junction_dict.items(): + search = self.loader.get_loader(dup_path, dup_provenance, load_subprojects=False) + if loader is search: + return True + + return False + ######################################################## # Private Methods # ######################################################## @@ -577,6 +619,7 @@ class Project: "remote-execution", "sources", "source-caches", + "junctions", "(@)", ] ) @@ -701,6 +744,18 @@ class Project: # Fatal warnings self._fatal_warnings = pre_config_node.get_str_list("fatal-warnings", default=[]) + # Junction configuration + junctions_node = pre_config_node.get_mapping("junctions", default={}) + junctions_node.validate_keys(["duplicates"]) + junction_duplicates = junctions_node.get_mapping("duplicates", default={}) + for project_name, junctions in junction_duplicates.items(): + # For each junction we preserve the provenance and the junction string, + # the provenance is used for lookups later on. + # + self._junction_duplicates[project_name] = junctions_dict = {} + for junction_node in junctions: + junctions_dict[junction_node.as_str()] = junction_node.get_provenance() + self.loader = Loader(self, parent=parent_loader, provenance=provenance) self._project_includes = Includes(self.loader, copy_tree=False) |