-
Notifications
You must be signed in to change notification settings - Fork 252
Add new functions to generate rust bindings in build.rs
#1444
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
base: main
Are you sure you want to change the base?
Conversation
Add `RustWasm::generate_to_out_dir` that parses the `wit` folder, selects a world, generates bindings and places them in a file in the `OUT_DIR`. `generate_to_out_dir_modify` allows modifying the generated file.
795fe7f to
4a43192
Compare
alexcrichton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Was there anything else you'd like to address before merging?
|
Thanks for the quick review! Additionally I would like to add a macro to include the generated file: #[cfg(feature = "macros")]
#[macro_export]
macro_rules! include_wit {
($name:literal) => {
include!(concat!(env!("OUT_DIR"), "/", $name, ".rs"));
};
}so that the bindings can be included simply with |
|
Personally I'd say that should be left out of the crate and documented in the usage of this method. I (subjectively) don't feel that clears the threshold for inclusion just yet, but if it becomes a common/frequent way of using wit-bindgen it seems ok to add. |
|
Understood, in that case the PR is done. |
|
Looks like an intermittent failure, so let's try again |
* Add new functions to generate rust bindings in `build.rs` Add `RustWasm::generate_to_out_dir` that parses the `wit` folder, selects a world, generates bindings and places them in a file in the `OUT_DIR`. `generate_to_out_dir_modify` allows modifying the generated file. * Use world name as output path in `generate_to_out_dir`
|
Sigh, I think Github infra might be having a bad day. I'll try again tomorrow |
Add
RustWasm::generate_to_out_dirthat parses thewitfolder, selects a world, generates bindings and places them in a file in theOUT_DIR.generate_to_out_dir_modifyallows modifying the generated file.Sample
build.rsThen the following snipped would include it:
Although this should be simplified as well.
Closes #1423