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

Support list of paths in component bindgen macro #9249

Closed
lwansbrough opened this issue Sep 15, 2024 · 6 comments · Fixed by #9288
Closed

Support list of paths in component bindgen macro #9249

lwansbrough opened this issue Sep 15, 2024 · 6 comments · Fixed by #9288

Comments

@lwansbrough
Copy link
Contributor

wit-bindgen includes the option to provide a list of paths for the wit sources. This makes it more practical to satisfy the requirements of imports from other packages. Enabling this behaviour for the component bindgen macro would be helpful.

wit-bindgen docs:

// Path to parse WIT and its dependencies from. Defaults to the `wit`
// folder adjacent to your `Cargo.toml`.
//
// This parameter also supports the form of a list, such as:
// ["../path/to/wit1", "../path/to/wit2"]
// Usually used in testing, our test suite may want to generate code
// from wit files located in multiple paths within a single mod, and we
// don't want to copy these files again.
path: "../path/to/wit",
@alexcrichton
Copy link
Member

Thanks for the report! To link things here this was implemented in wit-bindgen in bytecodealliance/wit-bindgen#1003 and I think it'd be reasonable to copy over a similar structure into Wasmtime as well. @lwansbrough would you be interested in creating a PR perhaps?

@lwansbrough
Copy link
Contributor Author

@alexcrichton I'll see what I can do.

I was looking through that commit and this looks like a bug to me. https://github.com/bytecodealliance/wit-bindgen/blob/3e3877da85daf1ed98bd1aee7007e496461c3bd1/crates/guest-rust/macro/src/lib.rs#L215

Line 237 passes root.join("wit") which would mean root is joined to root.

@alexcrichton
Copy link
Member

Good catch! Semantically that'll work out ok since "/a".join("/b") yields "/b", so the end result is the same. That being said it's unnecessarily complex, and just passing in "wit" instead of root.join("wit") should also work and be cleaner.

@MarinPostma
Copy link

Will this enable importing transitive dependencies of the package? Say I am generating binding for package A, but package A includes package B in a different directory, should I just be able to add the path to B and have it all work?

@alexcrichton
Copy link
Member

alexcrichton commented Sep 24, 2024

@MarinPostma I believe so yeah, but if it doesn't let me know!

@MarinPostma
Copy link

I'll give it a try then :)

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 a pull request may close this issue.

3 participants