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

Add component dependencies to metadata #1655

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

piotmag769
Copy link
Contributor

No description provided.

Comment on lines +108 to +110
pub fn to_discriminator(&self) -> String {
self.package_id.to_serialized_string()
}
Copy link
Contributor Author

@piotmag769 piotmag769 Oct 17, 2024

Choose a reason for hiding this comment

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

Changed discriminator to be serialized PackageId instead of Version to be aligned with the comment regarding CompilationUnitComponentDependencyMetadata::id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This requires changes to Cairo to work ^

Copy link
Contributor

Choose a reason for hiding this comment

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

This requires changes to Cairo to work ^

WDYM?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mean ProjectConfig is a terrible structure that sometimes has duplicated information, but sometimes lacks it (like in this case), so rn in RootDatabaseBuilder we set the discriminator to always be equal to CrateSetting.version

https://github.com/starkware-libs/cairo/blob/932767340c4b8a762140bf9eba305f437587ac1b/crates/cairo-lang-compiler/src/project.rs#L148-L152

scarb-metadata/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +108 to +110
pub fn to_discriminator(&self) -> String {
self.package_id.to_serialized_string()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires changes to Cairo to work ^

WDYM?

scarb/src/ops/resolve.rs Show resolved Hide resolved
scarb/src/ops/metadata.rs Show resolved Hide resolved
(
compilation_unit_component.package.id.name.to_string(),
DependencySettings {
discriminator: (compilation_unit_component.package.id.name.to_string()
!= *CORELIB_CRATE_NAME)
.then_some(compilation_unit_component.package.id.version.clone())
.map(|v| v.to_smolstr()),
.then_some(compilation_unit_component.id.clone())
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should hide the corelib edge case in cu too.

Copy link
Member

Choose a reason for hiding this comment

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

Definitely. I don't think we want all tools to think about this case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be fair it doesn't even matter from the compiler's point of view if the corelib discriminator is None or not as long as core is a dependency for each package (which it is in Scarb)

https://github.com/starkware-libs/cairo/blob/932767340c4b8a762140bf9eba305f437587ac1b/crates/cairo-lang-semantic/src/resolve/mod.rs#L1077

I agree though that we should keep it as None for consistency, will change it in metadata and Scarb's internal model

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure it does not matter? I know this has not been working without this if when we first introduced it. If we can omit this logic, it would be best to do so I think 🤔

Copy link
Member

Choose a reason for hiding this comment

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

scarb/src/compiler/db.rs Show resolved Hide resolved
scarb-metadata/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@mkaput mkaput left a comment

Choose a reason for hiding this comment

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

Looks good from scarb-metadata perspective. I haven't reviewed Scarb internals changes.

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.

Expose dependencies information in scarb metadata
3 participants