-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update to wit-bindgen 0.20.0 This commit updates the bindings generator to 0.20.0 and refactors the existing support for exporting macros to use the new features of 0.20.0 as well. The `macros` crate feature is now no longer required (yay!) and all the traits to implement are already present in the crate now. * Add more generated files to gitattributes * Remove macros feature from CI * Fix regenerate script * Rename macros back to their old names * Document some internal structure * More internal comments * Rename command macro * Fix doc test
- Loading branch information
1 parent
ded1722
commit e62af39
Showing
11 changed files
with
4,633 additions
and
3,431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
# This is generated by `wit-bindgen` | ||
# These are generated by `wit-bindgen` | ||
src/bindings.rs linguist-generated=true | ||
src/proxy.rs linguist-generated=true | ||
src/command.rs linguist-generated=true | ||
|
||
# This is copied from other repos so diffs aren't super interesting by default | ||
wit/deps linguist-generated=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,81 @@ | |
|
||
set -ex | ||
|
||
wit-bindgen rust wit --out-dir src --std-feature --type-section-suffix rust-wasi-from-crates-io | ||
generate() { | ||
file="$1" | ||
shift | ||
wit-bindgen rust wit --out-dir src --std-feature "$@" | ||
|
||
# rustfmt chokes on the raw output of wit-bindgen right now due to trailling | ||
# whitespace (unsure as to why), so format it with some options first to get it | ||
# into a better state before applying the final format with default options | ||
# which gets this to succeed. | ||
# rustfmt chokes on the raw output of wit-bindgen right now due to trailling | ||
# whitespace (unsure as to why), so format it with some options first to get it | ||
# into a better state before applying the final format with default options | ||
# which gets this to succeed. | ||
# | ||
# NB: this should be considered a bug in wit-bindgen that this is required to do | ||
# twice. Passing `--rustfmt` to `wit-bindgen` should work. | ||
rustfmt $file --edition 2021 --config-path ./ci/rustfmt-bindings.toml | ||
rustfmt $file --edition 2021 | ||
} | ||
|
||
# Generate the main body of the bindings which includes all imports from the two | ||
# worlds below. | ||
generate src/bindings.rs --type-section-suffix rust-wasi-from-crates-io | ||
|
||
# Generate bindings for the `wasi:cli/command` world specifically, namely the | ||
# macro `export_command`. | ||
# | ||
# NB: this should be considered a bug in wit-bindgen that this is required to do | ||
# twice. Passing `--rustfmt` to `wit-bindgen` should work. | ||
rustfmt src/bindings.rs --edition 2021 --config-path ./ci/rustfmt-bindings.toml | ||
rustfmt src/bindings.rs --edition 2021 | ||
# Note that `--with` is used to point at the previously generated bindings. | ||
with="wasi:cli/[email protected]=crate::cli::environment" | ||
with="$with,wasi:cli/[email protected]=crate::cli::exit" | ||
with="$with,wasi:cli/[email protected]=crate::cli::stdin" | ||
with="$with,wasi:cli/[email protected]=crate::cli::stdout" | ||
with="$with,wasi:cli/[email protected]=crate::cli::stderr" | ||
with="$with,wasi:cli/[email protected]=crate::cli::terminal_input" | ||
with="$with,wasi:cli/[email protected]=crate::cli::terminal_output" | ||
with="$with,wasi:cli/[email protected]=crate::cli::terminal_stdin" | ||
with="$with,wasi:cli/[email protected]=crate::cli::terminal_stdout" | ||
with="$with,wasi:cli/[email protected]=crate::cli::terminal_stderr" | ||
with="$with,wasi:clocks/[email protected]=crate::clocks::monotonic_clock" | ||
with="$with,wasi:clocks/[email protected]=crate::clocks::wall_clock" | ||
with="$with,wasi:filesystem/[email protected]=crate::filesystem::types" | ||
with="$with,wasi:filesystem/[email protected]=crate::filesystem::preopens" | ||
with="$with,wasi:io/[email protected]=crate::io::error" | ||
with="$with,wasi:io/[email protected]=crate::io::poll" | ||
with="$with,wasi:io/[email protected]=crate::io::streams" | ||
with="$with,wasi:random/[email protected]=crate::random::random" | ||
with="$with,wasi:random/[email protected]=crate::random::insecure" | ||
with="$with,wasi:random/[email protected]=crate::random::insecure_seed" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::network" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::instance_network" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::tcp" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::tcp_create_socket" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::udp" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::udp_create_socket" | ||
with="$with,wasi:sockets/[email protected]=crate::sockets::ip_name_lookup" | ||
generate src/command.rs \ | ||
--world wasi:cli/command \ | ||
--with "$with" \ | ||
--type-section-suffix rust-wasi-from-crates-io-command-world \ | ||
--default-bindings-module wasi \ | ||
--pub-export-macro \ | ||
--export-macro-name _export_command | ||
|
||
# Same as the `command` world, but for the proxy world. | ||
with="wasi:cli/[email protected]=crate::cli::stdin" | ||
with="$with,wasi:cli/[email protected]=crate::cli::stdout" | ||
with="$with,wasi:cli/[email protected]=crate::cli::stderr" | ||
with="$with,wasi:clocks/[email protected]=crate::clocks::monotonic_clock" | ||
with="$with,wasi:clocks/[email protected]=crate::clocks::wall_clock" | ||
with="$with,wasi:io/[email protected]=crate::io::error" | ||
with="$with,wasi:io/[email protected]=crate::io::poll" | ||
with="$with,wasi:io/[email protected]=crate::io::streams" | ||
with="$with,wasi:random/[email protected]=crate::random::random" | ||
with="$with,wasi:http/[email protected]=crate::http::types" | ||
with="$with,wasi:http/[email protected]=crate::http::outgoing_handler" | ||
generate src/proxy.rs \ | ||
--world wasi:http/proxy \ | ||
--with "$with" \ | ||
--type-section-suffix rust-wasi-from-crates-io-proxy-world \ | ||
--default-bindings-module wasi \ | ||
--pub-export-macro \ | ||
--export-macro-name _export_proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.