Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat Cairo plugins as package dependencies #1889

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

integraledelebesgue
Copy link

@integraledelebesgue integraledelebesgue commented Jan 16, 2025

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

Comment on lines +101 to +102
/// The ID of the [`CompilationUnitComponent`] the plugin is represented by in the [`CairoCompilationUnit`].
pub discriminator: CompilationUnitComponentId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary, you don't need to keep it here. You can just use the package.id.to_serialized_string in metadata builder

@@ -243,6 +243,9 @@ fn collect_cairo_compilation_unit_metadata(
.map(|c| {
m::CompilationUnitCairoPluginMetadataBuilder::default()
.package(wrap_package_id(c.package.id))
.discriminator(m::CompilationUnitComponentId {
repr: c.discriminator.package_id.to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fn wrap_package_id(id: PackageId) -> m::PackageId {

Suggested change
repr: c.discriminator.package_id.to_string(),
repr: c.discriminator.package_id.to_serialized_string(),

Also not needed here, check comment above

Comment on lines +423 to +424
/// An ID which uniquely identifies the plugin in scope of the Compilation Unit.
pub discriminator: Option<CompilationUnitComponentId>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// An ID which uniquely identifies the plugin in scope of the Compilation Unit.
pub discriminator: Option<CompilationUnitComponentId>,
/// An id which uniquely identifies the plugin in scope of the compilation unit amongst other plugins and [`CompilationUnitComponent`]s. It is used to identify the plugin as a possible dependency of a [`CompilationUnitComponent`].
pub component_dependency_id: Option<CompilationUnitComponentId>,

Please check other related docs as well (e.g. docs for CompilationUnitComponent.dependencies and CompilationUnitComponent.id) and update them to reflect the new semantics

Comment on lines +537 to +549
let member_plugin_dependencies = cairo_plugins
.iter()
.map(|plugin| plugin.discriminator.clone());

let member_component = components
.iter_mut()
.find(|component| component.package.id == member.id)
.unwrap();

member_component
.dependencies
.extend(member_plugin_dependencies);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand where it comes from. Isn't adding the plugin deps in component_dependencies enough?

Comment on lines +755 to +757
self.resolve
.package_dependencies(package_id, &TargetKind::CAIRO_PLUGIN)
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't treat the plugins globally (i.e. it treats packages like humanlike dependencies), does it?

Comment on lines +157 to +163
if unit.cairo_plugins
.iter()
.find(|plugin| plugin.discriminator == *compilation_unit_component_id)
.map(|plugin| (plugin.package.id.name.to_string(), plugin.discriminator.clone()))
.is_some() {
return None;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you filter them out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants