Skip to content

Update wit-bindgen-rust code generation to support cargo component.#394

Merged
alexcrichton merged 3 commits intobytecodealliance:mainfrom
peterhuene:update-rust-gen
Oct 24, 2022
Merged

Update wit-bindgen-rust code generation to support cargo component.#394
alexcrichton merged 3 commits intobytecodealliance:mainfrom
peterhuene:update-rust-gen

Conversation

@peterhuene
Copy link
Copy Markdown
Member

This PR adds some additional (optional) functionality that enables cargo component to generate bindings the way it wants.

  • Add a "call prefix" option for the export macro, which allows the bindings to be generated in a submodule, or in the case of cargo component, another crate.
  • Add an "export macro name" option that overrides the default name of the export macro; this allows cargo component to simply emit a new project with bindings::export!(Component).
  • Force a reference to the object file containing the component type custom section static so that it gets linked in when bindings are generated into a separate crate.

Peter Huene added 3 commits October 24, 2022 12:55
This commit adds an option for specifying a prefix to use for calls within the
generated `export!` macro.

It enables bindings to be generated into a submodule or crate and still have
the exports to call the appropriate generated functions.
This commit adds an option to control the export macro name.
This commit changes the generated `export!` macro to ensure a reference to the
object containing the component type section.

It is necessary to do this to prevent the linker from GC'ing the section's
static when building the bindings into a separate crate.
@alexcrichton alexcrichton merged commit bd89607 into bytecodealliance:main Oct 24, 2022
@peterhuene peterhuene deleted the update-rust-gen branch March 21, 2023 23:10
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