Skip to content

Resolution handler #1068

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

g-r-a-n-t
Copy link
Member

No description provided.

@g-r-a-n-t g-r-a-n-t marked this pull request as draft March 28, 2025 18:24
@g-r-a-n-t g-r-a-n-t marked this pull request as ready for review April 9, 2025 18:55
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch 2 times, most recently from a7ce31a to a61d9e9 Compare April 10, 2025 03:36
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch 5 times, most recently from fd31a02 to 06381f9 Compare April 22, 2025 15:58
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch 3 times, most recently from ec49518 to 5430d93 Compare April 28, 2025 19:59
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch 2 times, most recently from 685f878 to 1069810 Compare May 6, 2025 20:59
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch 3 times, most recently from f28fd37 to d0b347d Compare May 20, 2025 16:52
},
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct DependencyDescription {
pub url: Url,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might not be expressive enough to handle both relative and absolute dependency paths.

}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Dependency {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It could be really nice if Dependency is just a flat thing, something like:

Dependency {
  alias: SmolStr,
  location: Either<Url, Utf8PathBuf>,
  arguments: Option<IngotArguments>
}

Comment on lines 101 to 117
pub fn config(self, db: &'db dyn InputDb) -> Option<Config> {
db.workspace()
.containing_ingot_config_file(db, self.base(db))
.map(|config_file| Config::from_string(config_file.text(db).clone()))
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here's where the magic happens, where we just parse the config from the config's File input into a Config object. I added all the derivations to Config so that it can be salsa tracked.

@@ -47,16 +47,23 @@ impl ResolutionHandler<FilesResolver> for BasicIngotNodeHandler {
return config
.dependencies
.into_iter()
.map(|dependency| match dependency.description {
DependencyDescription::Path(path) => (
ingot_path.join(path).canonicalize_utf8().unwrap(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like the resolver was handling relative paths quite well before. If Dependency/DependencyDescription can only store a Url this gets trickier.

Copy link
Member Author

@g-r-a-n-t g-r-a-n-t May 21, 2025

Choose a reason for hiding this comment

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

I don't think the dependency struct should hold onto a url, unless it is a git repo or something. it should just be a simple representation of what is in the config file. it's pretty easy for a function in common::ingot to map a path DependencyDescription to a file url given the parent ingot.

.filter_map(
|Dependency {
alias,
description: DependencyDescription { url, .. },
Copy link
Collaborator

Choose a reason for hiding this comment

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

The oversimplified DependencyDescription with its handy Url is making this a little too easy. In the end we need to be able to consistently map a Dependency to a URL. In the case of relative path dependencies, there needs to be some way of injecting a base URL so that if the dependency points to a relative path we can resolve an absolute URL for that relative path.

Maybe we can have a method like:

impl Dependency {
  fn url(&self, base_url: Url) -> Url {
    let flattened_absolute_url = match self.location ... // handle path vs url
    return flattened_absolute_url
}

The idea would be that the dependency itself carries around either a url or a path and that this can be resolved given a base url.

}

#[salsa::tracked]
pub fn dependencies(self, db: &'db dyn InputDb) -> Vec<Dependency> {
Copy link
Member Author

Choose a reason for hiding this comment

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

this could just return the aliases and urls and the dependency descriptions can remain relative

@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch from caa2daf to f97a007 Compare May 22, 2025 17:19
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch from f97a007 to bee0e97 Compare June 2, 2025 12:46
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch from 109a9dd to 2154b82 Compare June 16, 2025 22:17
@g-r-a-n-t g-r-a-n-t force-pushed the resolution-handler branch from 2154b82 to 6b7285d Compare June 24, 2025 04:41
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