|
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/[email protected]=crate::cli::environment" |
| 30 | +with= "$with,wasi:cli/[email protected]=crate::cli::exit" |
| 31 | +with= "$with,wasi:cli/[email protected]=crate::cli::stdin" |
| 32 | +with= "$with,wasi:cli/[email protected]=crate::cli::stdout" |
| 33 | +with= "$with,wasi:cli/[email protected]=crate::cli::stderr" |
| 34 | +with= "$with,wasi:cli/[email protected]=crate::cli::terminal_input" |
| 35 | +with= "$with,wasi:cli/[email protected]=crate::cli::terminal_output" |
| 36 | +with= "$with,wasi:cli/[email protected]=crate::cli::terminal_stdin" |
| 37 | +with= "$with,wasi:cli/[email protected]=crate::cli::terminal_stdout" |
| 38 | +with= "$with,wasi:cli/[email protected]=crate::cli::terminal_stderr" |
| 39 | +with= "$with,wasi:clocks/[email protected]=crate::clocks::monotonic_clock" |
| 40 | +with= "$with,wasi:clocks/[email protected]=crate::clocks::wall_clock" |
| 41 | +with= "$with,wasi:filesystem/[email protected]=crate::filesystem::types" |
| 42 | +with= "$with,wasi:filesystem/[email protected]=crate::filesystem::preopens" |
| 43 | +with= "$with,wasi:io/[email protected]=crate::io::error" |
| 44 | +with= "$with,wasi:io/[email protected]=crate::io::poll" |
| 45 | +with= "$with,wasi:io/[email protected]=crate::io::streams" |
| 46 | +with= "$with,wasi:random/[email protected]=crate::random::random" |
| 47 | +with= "$with,wasi:random/[email protected]=crate::random::insecure" |
| 48 | +with= "$with,wasi:random/[email protected]=crate::random::insecure_seed" |
| 49 | +with= "$with,wasi:sockets/[email protected]=crate::sockets::network" |
| 50 | +with= "$with,wasi:sockets/[email protected]=crate::sockets::instance_network" |
| 51 | +with= "$with,wasi:sockets/[email protected]=crate::sockets::tcp" |
| 52 | +with= "$with,wasi:sockets/[email protected]=crate::sockets::tcp_create_socket" |
| 53 | +with= "$with,wasi:sockets/[email protected]=crate::sockets::udp" |
| 54 | +with= "$with,wasi:sockets/[email protected]=crate::sockets::udp_create_socket" |
| 55 | +with= "$with,wasi:sockets/[email protected]=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/[email protected]=crate::cli::stdin" |
| 66 | +with= "$with,wasi:cli/[email protected]=crate::cli::stdout" |
| 67 | +with= "$with,wasi:cli/[email protected]=crate::cli::stderr" |
| 68 | +with= "$with,wasi:clocks/[email protected]=crate::clocks::monotonic_clock" |
| 69 | +with= "$with,wasi:clocks/[email protected]=crate::clocks::wall_clock" |
| 70 | +with= "$with,wasi:io/[email protected]=crate::io::error" |
| 71 | +with= "$with,wasi:io/[email protected]=crate::io::poll" |
| 72 | +with= "$with,wasi:io/[email protected]=crate::io::streams" |
| 73 | +with= "$with,wasi:random/[email protected]=crate::random::random" |
| 74 | +with= "$with,wasi:http/[email protected]=crate::http::types" |
| 75 | +with= "$with,wasi:http/[email protected]=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