def execute(self): deferred_sources_fields = [] def find_deferred_sources_fields(target): for name, payload_field in target.payload.fields: if isinstance(payload_field, DeferredSourcesField): deferred_sources_fields.append((target, name, payload_field)) addresses = [target.address for target in self.context.targets()] self.context.build_graph.walk_transitive_dependency_graph(addresses, find_deferred_sources_fields) unpacked_sources = self.context.products.get_data('unpacked_archives') for (target, name, payload_field) in deferred_sources_fields: sources_target = self.context.build_graph.get_target(payload_field.address) if not sources_target: raise self.SourcesTargetLookupError( "Couldn't find {sources_spec} referenced from {target} field {name} in build graph" .format(sources_spec=payload_field.address.spec, target=target.address.spec, name=name)) if not sources_target in unpacked_sources: raise self.NoUnpackedSourcesError( "Target {sources_spec} referenced from {target} field {name} did not unpack any sources" .format(spec=sources_target.address.spec, target=target.address.spec, name=name)) sources, rel_unpack_dir = unpacked_sources[sources_target] SourceRoot.register_mutable(rel_unpack_dir) payload_field.populate(sources, rel_unpack_dir)
def root(path, *types): SourceRoot.register_mutable(os.path.join(parse_context.rel_path, basedir, path), *types)