Skip to content

Allow multiple library paths #2436

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: main
Choose a base branch
from
Open

Allow multiple library paths #2436

wants to merge 2 commits into from

Conversation

bcarlet
Copy link
Contributor

@bcarlet bcarlet commented Mar 27, 2025

This makes it possible to specify multiple library paths, which is useful for frontends that wish to provide their own primitive libraries in addition to Calyx's standard library.

Copy link
Contributor

@rachitnigam rachitnigam left a comment

Choose a reason for hiding this comment

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

Seems reasonable!

There is one breaking default in this PR that should be fixed.

Also: what happens when the same file name exists across many paths? I think we should generate an error instead of silently overriding an existing path file.

@bcarlet
Copy link
Contributor Author

bcarlet commented Mar 28, 2025

I've changed it so that it emits an error if it finds an import in multiple library paths.

Copy link
Contributor

This pull request has not seen activity in 14 days and is being marked as stale. If you're continuing work on this, please reply and state how to get this PR in a mergeable state or what issues it is blocked on. If the PR is not ready for review, please mark it as a draft. The PR will be closed in 7 days if there is no further activity.

@bcarlet
Copy link
Contributor Author

bcarlet commented Jun 3, 2025

@rachitnigam if the changes addressed your concerns then I'll go ahead and merge this?

@github-actions github-actions bot removed the S: Stale label Jun 3, 2025
Copy link
Collaborator

@EclecticGriffin EclecticGriffin 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 to me. Left some random nits that you can address or not as you please

@@ -19,11 +19,11 @@ fn cell_share_bench(c: &mut Criterion) {
let name =
format!("benches/component-sharing/{}.futil", name);
let bench = Path::new(&name);
let lib = Path::new(".");
let lib = [Path::new(".").to_path_buf()];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Silly nit that you can feel free to ignore. But might be better to just use PathBuf::from instead

let library_imports: Vec<_> = lib_paths
.iter()
.filter_map(|lib_path| {
let library_import = lib_path.join(import.clone());
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: clone() can be replaced with as_ref

Comment on lines +93 to +102
if library_imports.len() > 1 {
return Err(Error::misc(format!(
"Import path `{}` found in multiple library paths ({})",
import.as_ref().to_string_lossy(),
library_imports
.iter()
.map(|p| p.to_string_lossy())
.format(", ")
))
.with_pos(&import));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not super important, but I think these blocks could probably be arms of a match
on the len of library imports rather than a bunch of if with returns. Might be a
bit easier to parse?

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.

3 participants