in src/buildstream/element.py [0:0]
def _new_from_load_element(cls, load_element, task=None):
if not load_element.first_pass:
load_element.project.ensure_fully_loaded()
with suppress(KeyError):
return cls.__instantiated_elements[load_element]
element = load_element.project.create_element(load_element)
cls.__instantiated_elements[load_element] = element
# If the element implements configure_dependencies(), we will collect
# the dependency configurations for it, otherwise we will consider
# it an error to specify `config` on dependencies.
#
if element.configure_dependencies.__func__ is not Element.configure_dependencies:
custom_configurations = []
else:
custom_configurations = None
# Load the sources from the LoadElement
element.__load_sources(load_element)
# Instantiate dependencies
for dep in load_element.dependencies:
dependency = Element._new_from_load_element(dep.element, task)
if dep.dep_type & DependencyType.BUILD:
element.__build_dependencies.append(dependency)
dependency.__reverse_build_deps.add(element)
# Configuration data is only collected for build dependencies,
# if configuration data is specified on a runtime dependency
# then the assertion will be raised by the LoadElement.
#
if custom_configurations is not None:
# Create a proxy for the dependency
dep_proxy = cast("Element", ElementProxy(element, dependency))
# Class supports dependency configuration
if dep.config_nodes:
# Ensure variables are substituted first
#
for config in dep.config_nodes:
element.__variables.expand(config)
custom_configurations.extend(
[DependencyConfiguration(dep_proxy, dep.path, config) for config in dep.config_nodes]
)
else:
custom_configurations.append(DependencyConfiguration(dep_proxy, dep.path, None))
elif dep.config_nodes:
# Class does not support dependency configuration
provenance = dep.config_nodes[0].get_provenance()
raise LoadError(
"{}: Custom dependency configuration is not supported by element plugin '{}'".format(
provenance, element.get_kind()
),
LoadErrorReason.INVALID_DEPENDENCY_CONFIG,
)
if dep.dep_type & DependencyType.RUNTIME:
element.__runtime_dependencies.append(dependency)
dependency.__reverse_runtime_deps.add(element)
if dep.strict:
element.__strict_dependencies.append(dependency)
no_of_runtime_deps = len(element.__runtime_dependencies)
element.__runtime_deps_uncached = no_of_runtime_deps
no_of_build_deps = len(element.__build_dependencies)
element.__build_deps_uncached = no_of_build_deps
if custom_configurations is not None:
element.configure_dependencies(custom_configurations)
element.__preflight()
element._initialize_state()
if task:
task.add_current_progress()
return element