Add a wasmtime::component::bindgen! macro (#5317)
* Import Wasmtime support from the `wit-bindgen` repo This commit imports the `wit-bindgen-gen-host-wasmtime-rust` crate from the `wit-bindgen` repository into the upstream Wasmtime repository. I've chosen to not import the full history here since the crate is relatively small and doesn't have a ton of complexity. While the history of the crate is quite long the current iteration of the crate's history is relatively short so there's not a ton of import there anyway. The thinking is that this can now continue to evolve in-tree. * Refactor `wasmtime-component-macro` a bit Make room for a `wit_bindgen` macro to slot in. * Add initial support for a `bindgen` macro * Add tests for `wasmtime::component::bindgen!` * Improve error forgetting `async` feature * Add end-to-end tests for bindgen * Add an audit of `unicase` * Add a license to the test-helpers crate * Add vet entry for `pulldown-cmark` * Update publish script with new crate * Try to fix publish script * Update audits * Update lock file
This commit is contained in:
13
crates/component-macro/test-helpers/Cargo.toml
Normal file
13
crates/component-macro/test-helpers/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "component-macro-test-helpers"
|
||||
version = "0.0.0"
|
||||
edition.workspace = true
|
||||
publish = false
|
||||
license = "Apache-2.0 WITH LLVM-exception"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
proc-macro2 = "1.0"
|
||||
quote = "1.0"
|
||||
23
crates/component-macro/test-helpers/src/lib.rs
Normal file
23
crates/component-macro/test-helpers/src/lib.rs
Normal file
@@ -0,0 +1,23 @@
|
||||
use proc_macro::TokenStream;
|
||||
use proc_macro2::{Ident, Span};
|
||||
use quote::quote;
|
||||
|
||||
#[proc_macro]
|
||||
pub fn foreach(input: TokenStream) -> TokenStream {
|
||||
let input = proc_macro2::TokenStream::from(input);
|
||||
let mut cwd = std::env::current_dir().unwrap();
|
||||
cwd.push("crates/component-macro/tests/codegen");
|
||||
let mut result = Vec::new();
|
||||
for f in cwd.read_dir().unwrap() {
|
||||
let f = f.unwrap().path();
|
||||
if f.extension().and_then(|s| s.to_str()) == Some("wit") {
|
||||
let name = f.file_stem().unwrap().to_str().unwrap();
|
||||
let name = Ident::new(&name.replace("-", "_"), Span::call_site());
|
||||
let path = f.to_str().unwrap();
|
||||
result.push(quote! {
|
||||
#input!(#name #path);
|
||||
});
|
||||
}
|
||||
}
|
||||
(quote!( #(#result)*)).into()
|
||||
}
|
||||
Reference in New Issue
Block a user