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 only_interfaces and with to the bindgen! macro. #6160

Merged

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Apr 5, 2023

Add the only_interfaces and with options to the bindgen! macro. These two additional options enable the definitions of a use of bindgen! to be split up and reused in the following way:

  • Passing only_interfaces: true to an invocation of bindgen! will cause only the interfaces depended on by the supplied world to be generated, allowing the interface definitions depended on by two world files to be shared.
  • Passing with: { "a": module::name } allows references to the a import to be remapped to a known module, in this case module::name. When this option is supplied, no code will be generated for the interface a, assuming that those definitions came from a previous use of bindgen! with only_interfaces: true.

Here's a use in the preview2-prototyping repository for a motivating example of how this can be used with the command world.

@elliottt elliottt marked this pull request as ready for review April 5, 2023 23:08
@elliottt elliottt requested a review from a team as a code owner April 5, 2023 23:08
Copy link
Member

@alexcrichton alexcrichton 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 to me! Can you add some updated docs to crates/wasmtime/src/component.rs as well which should have a big doc-block on the reexport of the bindgen! macro for this.

crates/component-macro/src/bindgen.rs Outdated Show resolved Hide resolved
@elliottt elliottt force-pushed the trevor/bindgen-only-interfaces branch from f62bffc to d4a2e09 Compare April 10, 2023 22:25
@elliottt elliottt added this pull request to the merge queue Apr 10, 2023
Merged via the queue into bytecodealliance:main with commit 85f0c68 Apr 11, 2023
@elliottt elliottt deleted the trevor/bindgen-only-interfaces branch April 11, 2023 00:08
brendandburns pushed a commit to brendandburns/wasmtime that referenced this pull request Apr 13, 2023
…liance#6160)

* Add `only_interfaces` and `with` to the `bindgen!` macro.

* Add a version of the empty_error test for `only_interfaces` and `with`

* Review feedback

* Add docs
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