Add new functions to generate rust bindings in build.rs#1444
Add new functions to generate rust bindings in build.rs#1444tschneidereit merged 2 commits intobytecodealliance:mainfrom
build.rs#1444Conversation
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.
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