-
Notifications
You must be signed in to change notification settings - Fork 71
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
base: spr/main/8452ee94
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,8 @@ pub struct CompilationUnitComponent { | |
#[derive(Clone, Debug, TypedBuilder)] | ||
#[non_exhaustive] | ||
pub struct CompilationUnitCairoPlugin { | ||
/// The ID of the [`CompilationUnitComponent`] the plugin is represented by in the [`CairoCompilationUnit`]. | ||
pub discriminator: CompilationUnitComponentId, | ||
Comment on lines
+101
to
+102
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
/// The Scarb plugin [`Package`] to load. | ||
pub package: Package, | ||
/// Indicate whether the plugin is built into Scarb, or compiled from source. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,15 +153,23 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result<ProjectConfig> { | |
let dependencies = component | ||
.dependencies | ||
.iter() | ||
.map(|compilation_unit_component_id| { | ||
.filter_map(|compilation_unit_component_id| { | ||
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; | ||
} | ||
Comment on lines
+157
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you filter them out? |
||
|
||
let compilation_unit_component = unit.components.iter().find(|component| component.id == *compilation_unit_component_id) | ||
.expect("dependency of a component is guaranteed to exist in compilation unit components"); | ||
( | ||
Some(( | ||
compilation_unit_component.cairo_package_name().to_string(), | ||
DependencySettings { | ||
discriminator: compilation_unit_component.id.to_discriminator() | ||
}, | ||
) | ||
)) | ||
}) | ||
.collect(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check other related docs as well (e.g. docs for
CompilationUnitComponent.dependencies
andCompilationUnitComponent.id
) and update them to reflect the new semantics