|
2 | 2 |
|
3 | 3 | set -ex |
4 | 4 |
|
5 | | -wit-bindgen rust wit --out-dir src --std-feature --type-section-suffix rust-wasi-from-crates-io |
| 5 | +generate() { |
| 6 | + file="$1" |
| 7 | + shift |
| 8 | + wit-bindgen rust wit --out-dir src --std-feature "$@" |
6 | 9 |
|
7 | | -# rustfmt chokes on the raw output of wit-bindgen right now due to trailling |
8 | | -# whitespace (unsure as to why), so format it with some options first to get it |
9 | | -# into a better state before applying the final format with default options |
10 | | -# which gets this to succeed. |
| 10 | + # rustfmt chokes on the raw output of wit-bindgen right now due to trailling |
| 11 | + # whitespace (unsure as to why), so format it with some options first to get it |
| 12 | + # into a better state before applying the final format with default options |
| 13 | + # which gets this to succeed. |
| 14 | + # |
| 15 | + # NB: this should be considered a bug in wit-bindgen that this is required to do |
| 16 | + # twice. Passing `--rustfmt` to `wit-bindgen` should work. |
| 17 | + rustfmt $file --edition 2021 --config-path ./ci/rustfmt-bindings.toml |
| 18 | + rustfmt $file --edition 2021 |
| 19 | +} |
| 20 | + |
| 21 | +# Generate the main body of the bindings which includes all imports from the two |
| 22 | +# worlds below. |
| 23 | +generate src/bindings.rs --type-section-suffix rust-wasi-from-crates-io |
| 24 | + |
| 25 | +# Generate bindings for the `wasi:cli/command` world specifically, namely the |
| 26 | +# macro `export_command`. |
11 | 27 | # |
12 | | -# NB: this should be considered a bug in wit-bindgen that this is required to do |
13 | | -# twice. Passing `--rustfmt` to `wit-bindgen` should work. |
14 | | -rustfmt src/bindings.rs --edition 2021 --config-path ./ci/rustfmt-bindings.toml |
15 | | -rustfmt src/bindings.rs --edition 2021 |
| 28 | +# Note that `--with` is used to point at the previously generated bindings. |
| 29 | +with="wasi:cli/environment@0.2.0=crate::cli::environment" |
| 30 | +with="$with,wasi:cli/exit@0.2.0=crate::cli::exit" |
| 31 | +with="$with,wasi:cli/stdin@0.2.0=crate::cli::stdin" |
| 32 | +with="$with,wasi:cli/stdout@0.2.0=crate::cli::stdout" |
| 33 | +with="$with,wasi:cli/stderr@0.2.0=crate::cli::stderr" |
| 34 | +with="$with,wasi:cli/terminal-input@0.2.0=crate::cli::terminal_input" |
| 35 | +with="$with,wasi:cli/terminal-output@0.2.0=crate::cli::terminal_output" |
| 36 | +with="$with,wasi:cli/terminal-stdin@0.2.0=crate::cli::terminal_stdin" |
| 37 | +with="$with,wasi:cli/terminal-stdout@0.2.0=crate::cli::terminal_stdout" |
| 38 | +with="$with,wasi:cli/terminal-stderr@0.2.0=crate::cli::terminal_stderr" |
| 39 | +with="$with,wasi:clocks/monotonic-clock@0.2.0=crate::clocks::monotonic_clock" |
| 40 | +with="$with,wasi:clocks/wall-clock@0.2.0=crate::clocks::wall_clock" |
| 41 | +with="$with,wasi:filesystem/types@0.2.0=crate::filesystem::types" |
| 42 | +with="$with,wasi:filesystem/preopens@0.2.0=crate::filesystem::preopens" |
| 43 | +with="$with,wasi:io/error@0.2.0=crate::io::error" |
| 44 | +with="$with,wasi:io/poll@0.2.0=crate::io::poll" |
| 45 | +with="$with,wasi:io/streams@0.2.0=crate::io::streams" |
| 46 | +with="$with,wasi:random/random@0.2.0=crate::random::random" |
| 47 | +with="$with,wasi:random/insecure@0.2.0=crate::random::insecure" |
| 48 | +with="$with,wasi:random/insecure-seed@0.2.0=crate::random::insecure_seed" |
| 49 | +with="$with,wasi:sockets/network@0.2.0=crate::sockets::network" |
| 50 | +with="$with,wasi:sockets/instance-network@0.2.0=crate::sockets::instance_network" |
| 51 | +with="$with,wasi:sockets/tcp@0.2.0=crate::sockets::tcp" |
| 52 | +with="$with,wasi:sockets/tcp-create-socket@0.2.0=crate::sockets::tcp_create_socket" |
| 53 | +with="$with,wasi:sockets/udp@0.2.0=crate::sockets::udp" |
| 54 | +with="$with,wasi:sockets/udp-create-socket@0.2.0=crate::sockets::udp_create_socket" |
| 55 | +with="$with,wasi:sockets/ip-name-lookup@0.2.0=crate::sockets::ip_name_lookup" |
| 56 | +generate src/command.rs \ |
| 57 | + --world wasi:cli/command \ |
| 58 | + --with "$with" \ |
| 59 | + --type-section-suffix rust-wasi-from-crates-io-command-world \ |
| 60 | + --default-bindings-module wasi \ |
| 61 | + --pub-export-macro \ |
| 62 | + --export-macro-name _export_command |
| 63 | + |
| 64 | +# Same as the `command` world, but for the proxy world. |
| 65 | +with="wasi:cli/stdin@0.2.0=crate::cli::stdin" |
| 66 | +with="$with,wasi:cli/stdout@0.2.0=crate::cli::stdout" |
| 67 | +with="$with,wasi:cli/stderr@0.2.0=crate::cli::stderr" |
| 68 | +with="$with,wasi:clocks/monotonic-clock@0.2.0=crate::clocks::monotonic_clock" |
| 69 | +with="$with,wasi:clocks/wall-clock@0.2.0=crate::clocks::wall_clock" |
| 70 | +with="$with,wasi:io/error@0.2.0=crate::io::error" |
| 71 | +with="$with,wasi:io/poll@0.2.0=crate::io::poll" |
| 72 | +with="$with,wasi:io/streams@0.2.0=crate::io::streams" |
| 73 | +with="$with,wasi:random/random@0.2.0=crate::random::random" |
| 74 | +with="$with,wasi:http/types@0.2.0=crate::http::types" |
| 75 | +with="$with,wasi:http/outgoing-handler@0.2.0=crate::http::outgoing_handler" |
| 76 | +generate src/proxy.rs \ |
| 77 | + --world wasi:http/proxy \ |
| 78 | + --with "$with" \ |
| 79 | + --type-section-suffix rust-wasi-from-crates-io-proxy-world \ |
| 80 | + --default-bindings-module wasi \ |
| 81 | + --pub-export-macro \ |
| 82 | + --export-macro-name _export_proxy |
0 commit comments