diff --git a/Cargo.lock b/Cargo.lock index 09d04d8..aaeba5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,9 +330,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "foldhash" -version = "0.1.5" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "form_urlencoded" @@ -447,19 +447,13 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "foldhash", ] -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" - [[package]] name = "heck" version = "0.5.0" @@ -652,9 +646,9 @@ dependencies = [ [[package]] name = "id-arena" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" [[package]] name = "idna" @@ -684,7 +678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", - "hashbrown 0.16.1", + "hashbrown", "serde", "serde_core", ] @@ -1727,9 +1721,9 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.244.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +checksum = "3f9dca005e69bf015e45577e415b9af8c67e8ee3c0e38b5b0add5aa92581ed5c" dependencies = [ "leb128fmt", "wasmparser", @@ -1737,9 +1731,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.244.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +checksum = "da55e60097e8b37b475a0fa35c3420dd71d9eb7bd66109978ab55faf56a57efb" dependencies = [ "anyhow", "indexmap", @@ -1749,21 +1743,21 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.244.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +checksum = "4f08c9adee0428b7bddf3890fc27e015ac4b761cc608c822667102b8bfd6995e" dependencies = [ "bitflags", - "hashbrown 0.15.5", + "hashbrown", "indexmap", "semver", ] [[package]] name = "wast" -version = "244.0.0" +version = "245.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2e7b9f9e23311275920e3d6b56d64137c160cf8af4f84a7283b36cfecbf4acb" +checksum = "28cf1149285569120b8ce39db8b465e8a2b55c34cbb586bd977e43e2bc7300bf" dependencies = [ "bumpalo", "leb128fmt", @@ -1774,9 +1768,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.244.0" +version = "1.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbf35b87ed352f9ab6cd0732abde5a67dd6153dfd02c493e61459218b19456fa" +checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be" dependencies = [ "wast", ] @@ -2084,8 +2078,8 @@ checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] name = "wit-bindgen-core" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=822fdb1ae6279933be9f0a6b18901adf9997398d#822fdb1ae6279933be9f0a6b18901adf9997398d" +version = "0.53.1" +source = "git+https://github.com/asteurer/wit-bindgen?rev=ad98571fdd93de6057c4572e16ba5c6f5ac17ae7#ad98571fdd93de6057c4572e16ba5c6f5ac17ae7" dependencies = [ "anyhow", "heck", @@ -2094,8 +2088,8 @@ dependencies = [ [[package]] name = "wit-bindgen-go" -version = "0.51.0" -source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=822fdb1ae6279933be9f0a6b18901adf9997398d#822fdb1ae6279933be9f0a6b18901adf9997398d" +version = "0.53.1" +source = "git+https://github.com/asteurer/wit-bindgen?rev=ad98571fdd93de6057c4572e16ba5c6f5ac17ae7#ad98571fdd93de6057c4572e16ba5c6f5ac17ae7" dependencies = [ "anyhow", "heck", @@ -2107,9 +2101,9 @@ dependencies = [ [[package]] name = "wit-component" -version = "0.244.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +checksum = "4894f10d2d5cbc17c77e91f86a1e48e191a788da4425293b55c98b44ba3fcac9" dependencies = [ "anyhow", "bitflags", @@ -2126,11 +2120,12 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.244.0" +version = "0.245.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +checksum = "330698718e82983499419494dd1e3d7811a457a9bf9f69734e8c5f07a2547929" dependencies = [ "anyhow", + "hashbrown", "id-arena", "indexmap", "log", diff --git a/Cargo.toml b/Cargo.toml index 0319ddb..9926816 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,7 @@ allow_attributes_without_reason = 'warn' anyhow = { workspace = true} clap = { version = "4.5.53", features = ["derive"] } regex = "1.12.2" -wat = { version = "1.243.0"} -# TODO: Update once v0.52.0 releases -wit-bindgen-go = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "822fdb1ae6279933be9f0a6b18901adf9997398d" } -wit-component = "0.244.0" -wit-parser = "0.244.0" +wat = { version = "1.245.1"} +wit-bindgen-go = { git = "https://github.com/asteurer/wit-bindgen", rev = "ad98571fdd93de6057c4572e16ba5c6f5ac17ae7" } +wit-component = "0.245.1" +wit-parser = "0.245.1" diff --git a/examples/wasip2/README.md b/examples/wasip2/README.md index 428eb7c..e8d7bf4 100644 --- a/examples/wasip2/README.md +++ b/examples/wasip2/README.md @@ -3,7 +3,7 @@ ### Prerequisites - [**componentize-go**](https://github.com/bytecodealliance/componentize-go) - Latest version - [**go**](https://go.dev/dl/) - v1.25+ -- [**wasmtime**](https://github.com/bytecodealliance/wasmtime) - Latest version +- [**wasmtime**](https://github.com/bytecodealliance/wasmtime) - v40.0.2 ### Run ```sh diff --git a/examples/wasip2/export_wasi_http_incoming_handler/handler.go b/examples/wasip2/export_wasi_http_incoming_handler/handler.go index 8c76e35..9f55181 100644 --- a/examples/wasip2/export_wasi_http_incoming_handler/handler.go +++ b/examples/wasip2/export_wasi_http_incoming_handler/handler.go @@ -3,7 +3,7 @@ package export_wasi_http_incoming_handler import ( . "wit_component/wasi_http_types" - . "github.com/bytecodealliance/wit-bindgen/wit_types" + . "go.bytecodealliance.org/pkg/wit/types" ) // Handle the specified `Request`, returning a `Response` diff --git a/examples/wasip3/README.md b/examples/wasip3/README.md index 8f9d60d..24edbae 100644 --- a/examples/wasip3/README.md +++ b/examples/wasip3/README.md @@ -14,7 +14,7 @@ everything is merged, we'll be able to switch to the upstream releases. ### Prerequisites - [**componentize-go**](https://github.com/bytecodealliance/componentize-go) - Latest version - [**go**](https://github.com/dicej/go/releases/tag/go1.25.5-wasi-on-idle) - The [Makefile](./Makefile) installs the patched version of Go. -- [**wasmtime**](https://github.com/bytecodealliance/wasmtime) - Latest version +- [**wasmtime**](https://github.com/bytecodealliance/wasmtime) - v40.0.2 This will build the dependencies, generate Go bindings from the `wasi:http@0.3.0-rc-2025-09-16` WIT files, build the component, and run it using diff --git a/examples/wasip3/export_wasi_http_handler/handler.go b/examples/wasip3/export_wasi_http_handler/handler.go index 198c617..c878458 100644 --- a/examples/wasip3/export_wasi_http_handler/handler.go +++ b/examples/wasip3/export_wasi_http_handler/handler.go @@ -8,7 +8,7 @@ import ( "wit_component/wasi_http_handler" . "wit_component/wasi_http_types" - . "github.com/bytecodealliance/wit-bindgen/wit_types" + . "go.bytecodealliance.org/pkg/wit/types" ) // Handle the specified `Request`, returning a `Response` @@ -58,7 +58,7 @@ func Handle(request *Request) Result[*Response, ErrorCode] { channel := make(chan Tuple2[string, string]) for _, url := range urls { go func() { - channel <- Tuple2[string, string]{url, getSha256(url)} + channel <- Tuple2[string, string]{F0: url, F1: getSha256(url)} }() } @@ -70,7 +70,7 @@ func Handle(request *Request) Result[*Response, ErrorCode] { response, send := ResponseNew( FieldsFromList([]Tuple2[string, []uint8]{ - Tuple2[string, []uint8]{"content-type", []uint8("text/plain")}, + {F0: "content-type", F1: []uint8("text/plain")}, }).Ok(), Some(rx), trailersFuture(), diff --git a/src/bindings.rs b/src/bindings.rs index f14ea11..3cc37bd 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -13,7 +13,7 @@ pub fn generate_bindings( output: Option<&Path>, pkg_name: Option, ) -> Result<()> { - let (resolve, world) = parse_wit(wit_path, world, features, all_features)?; + let (mut resolve, world) = parse_wit(wit_path, world, features, all_features)?; let mut files = Default::default(); let format = if should_format { @@ -22,6 +22,16 @@ pub fn generate_bindings( wit_bindgen_go::Format::False }; + // If the user wants to create a package rather than a standalone binary, provide them with the + // go.bytecodealliance.org/pkg version that needs to be placed in their go.mod file + let mut message: Option = None; + if pkg_name.is_some() { + message = Some(format!( + "Success! Please add the following line to your 'go.mod' file:\n\nrequire {}", + wit_bindgen_go::remote_pkg_version() + )); + } + wit_bindgen_go::Opts { generate_stubs, format, @@ -29,7 +39,7 @@ pub fn generate_bindings( ..Default::default() } .build() - .generate(&resolve, world, &mut files)?; + .generate(&mut resolve, world, &mut files)?; let output_path = match output { Some(p) => make_path_absolute(&p.to_path_buf())?, @@ -45,5 +55,9 @@ pub fn generate_bindings( std::fs::write(&file_path, contents)?; } + if let Some(msg) = message { + println!("{msg}"); + } + Ok(()) }