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

Implement unlocked-dep imports for component dependencies. #230

Merged
merged 4 commits into from
Feb 22, 2024

Conversation

peterhuene
Copy link
Member

This PR implements outputting a component with unlocked-dep imports for
any component dependencies specified in Cargo.toml.

Note that WIT does not support the nesting of interfaces (i.e.
instances), so to properly bind to a component's exports, an instance is
imported for its directly exported functions and then one for every instance
the component exports.

Therefore, depending on a component may result in more than one import
dependency for that package; one of the imports might be for
unlocked-dep=<foo:bar>, while others might be of the form
unlocked-dep=<foo:bar/<export>>.

Additionally, this contains a breaking change to bindings for component dependencies;
component dependencies are now namespaced, so to access function baz of package
foo:bar goes from bindings::bar::baz to bindings::foo_bar::baz. Similarly, interfaces
exported by foo:bar are go from bindings::bar::<name> to bindings::foo_bar::<name>.

Dependencies have also been updated to latest, including 0.3.0 of warg.

This commit implements outputting a component with `unlocked-dep` imports for
any component dependencies specified in `Cargo.toml`.

Note that WIT does not support the nesting of interfaces (i.e.
instances), so to properly bind to a component's exports, an instance is
imported for its directly exported functions and then one for every instance
the component exports.

Therefore, depending on a component may result in more than one import
dependency for that package; one of the imports might be for
`unlocked-dep=<foo:bar>`, while others might be of the form
`unlocked-dep=<foo:bar/<export>>`.
This includes a rename of `PackageId` to `PackageName` in various places.
The import name used in the bindings is the `id_of` the interface, and not just
the interface name.
@sunfishcode sunfishcode merged commit 7aed1ce into bytecodealliance:main Feb 22, 2024
6 checks passed
@peterhuene peterhuene deleted the unlocked-deps branch February 22, 2024 23:25
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.

None yet

2 participants