Skip to content

Commit

Permalink
use wasi-http and wasi-cli 0.2.0-rc-2023-12-05 (#7640) (#7650)
Browse files Browse the repository at this point in the history
* wasi-cli: update to version 0.2.0-rc-2023-12-05

* wasi-http: update to 0.2.0-rc-2023-12-05

* fix versions in extra (non-wasi) wits

* component adapter: fixes to use cli/imports world, correct versions

* wasmtime-wasi: cli/reactor is now cli/imports

* sync wasi-http/wit with wasi/wit

* fix cli-test component-basic.wat version

Co-authored-by: Pat Hickey <[email protected]>
  • Loading branch information
ricochet and Pat Hickey authored Dec 6, 2023
1 parent debce60 commit 759aa58
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 102 deletions.
6 changes: 3 additions & 3 deletions crates/wasi-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub mod bindings {
wasmtime::component::bindgen!({
path: "wit",
interfaces: "
import wasi:http/[email protected]11-10;
import wasi:http/[email protected]11-10;
import wasi:http/[email protected]11-10;
import wasi:http/[email protected]12-05;
import wasi:http/[email protected]12-05;
import wasi:http/[email protected]12-05;
",
tracing: true,
async: false,
Expand Down
4 changes: 2 additions & 2 deletions crates/wasi-http/wit/command-extended.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// All of the same imports and exports available in the wasi:cli/command world
// with addition of HTTP proxy related imports:
world command-extended {
include wasi:cli/command@0.2.0-rc-2023-11-10;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-10;
include wasi:cli/command@0.2.0-rc-2023-12-05;
import wasi:http/outgoing-handler@0.2.0-rc-2023-12-05;
}
4 changes: 2 additions & 2 deletions crates/wasi-http/wit/deps/cli/command.wit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package wasi:cli@0.2.0-rc-2023-11-10;
package wasi:cli@0.2.0-rc-2023-12-05;

world command {
include reactor;
include imports;

export run;
}
20 changes: 20 additions & 0 deletions crates/wasi-http/wit/deps/cli/imports.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package wasi:cli@0.2.0-rc-2023-12-05;

world imports {
include wasi:clocks/imports@0.2.0-rc-2023-11-10;
include wasi:filesystem/imports@0.2.0-rc-2023-11-10;
include wasi:sockets/imports@0.2.0-rc-2023-11-10;
include wasi:random/imports@0.2.0-rc-2023-11-10;
include wasi:io/imports@0.2.0-rc-2023-11-10;

import environment;
import exit;
import stdin;
import stdout;
import stderr;
import terminal-input;
import terminal-output;
import terminal-stdin;
import terminal-stdout;
import terminal-stderr;
}
31 changes: 0 additions & 31 deletions crates/wasi-http/wit/deps/cli/reactor.wit

This file was deleted.

11 changes: 5 additions & 6 deletions crates/wasi-http/wit/deps/http/proxy.wit
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package wasi:http@0.2.0-rc-2023-11-10;
package wasi:http@0.2.0-rc-2023-12-05;

/// The `wasi:http/proxy` world captures a widely-implementable intersection of
/// hosts that includes HTTP forward and reverse proxies. Components targeting
/// this world may concurrently stream in and out any number of incoming and
/// outgoing HTTP requests.
world proxy {
/// HTTP proxies have access to time and randomness.
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10;
include wasi:clocks/imports@0.2.0-rc-2023-11-10;
import wasi:random/random@0.2.0-rc-2023-11-10;

/// Proxies have standard output and error streams which are expected to
/// terminate in a developer-facing console provided by the host.
import wasi:cli/stdout@0.2.0-rc-2023-11-10;
import wasi:cli/stderr@0.2.0-rc-2023-11-10;
import wasi:cli/stdout@0.2.0-rc-2023-12-05;
import wasi:cli/stderr@0.2.0-rc-2023-12-05;

/// TODO: this is a temporary workaround until component tooling is able to
/// gracefully handle the absence of stdin. Hosts must return an eof stream
/// for this import, which is what wasi-libc + tooling will do automatically
/// when this import is properly removed.
import wasi:cli/stdin@0.2.0-rc-2023-11-10;
import wasi:cli/stdin@0.2.0-rc-2023-12-05;

/// This is the default handler to use when user code simply wants to make an
/// HTTP request (e.g., via `fetch()`).
Expand Down
8 changes: 4 additions & 4 deletions crates/wasi-http/wit/test.wit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package wasmtime:wasi;

// only used as part of `test-programs`
world test-reactor {
include wasi:cli/reactor@0.2.0-rc-2023-11-10;
include wasi:cli/imports@0.2.0-rc-2023-12-05;

export add-strings: func(s: list<string>) -> u32;
export get-strings: func() -> list<string>;
Expand All @@ -16,7 +16,7 @@ world test-reactor {
}

world test-command {
include wasi:cli/reactor@0.2.0-rc-2023-11-10;
import wasi:http/types@0.2.0-rc-2023-11-10;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-10;
include wasi:cli/imports@0.2.0-rc-2023-12-05;
import wasi:http/types@0.2.0-rc-2023-12-05;
import wasi:http/outgoing-handler@0.2.0-rc-2023-12-05;
}
14 changes: 7 additions & 7 deletions crates/wasi-preview1-component-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub mod bindings {
#[cfg(feature = "reactor")]
wit_bindgen::generate!({
path: "../wasi/wit",
world: "wasi:cli/reactor",
world: "wasi:cli/imports",
std_feature,
raw_strings,
// Automatically generated bindings for these functions will allocate
Expand All @@ -87,9 +87,9 @@ pub mod bindings {
import wasi:clocks/[email protected];
import wasi:clocks/[email protected];
import wasi:random/[email protected];
import wasi:cli/[email protected]11-10;
import wasi:cli/[email protected]11-10;
import wasi:cli/[email protected]11-10;
import wasi:cli/[email protected]12-05;
import wasi:cli/[email protected]12-05;
import wasi:cli/[email protected]12-05;
}
"#,
std_feature,
Expand All @@ -98,7 +98,7 @@ pub mod bindings {
});
}

#[export_name = "wasi:cli/[email protected]11-10#run"]
#[export_name = "wasi:cli/[email protected]12-05#run"]
#[cfg(feature = "command")]
pub unsafe extern "C" fn run() -> u32 {
#[link(wasm_import_module = "__main_module__")]
Expand Down Expand Up @@ -2641,7 +2641,7 @@ impl State {
#[cfg(not(feature = "proxy"))]
fn get_environment(&self) -> &[StrTuple] {
if self.env_vars.get().is_none() {
#[link(wasm_import_module = "wasi:cli/[email protected]11-10")]
#[link(wasm_import_module = "wasi:cli/[email protected]12-05")]
extern "C" {
#[link_name = "get-environment"]
fn get_environment_import(rval: *mut StrTupleList);
Expand All @@ -2666,7 +2666,7 @@ impl State {
#[cfg(not(feature = "proxy"))]
fn get_args(&self) -> &[WasmStr] {
if self.args.get().is_none() {
#[link(wasm_import_module = "wasi:cli/[email protected]11-10")]
#[link(wasm_import_module = "wasi:cli/[email protected]12-05")]
extern "C" {
#[link_name = "get-arguments"]
fn get_args_import(rval: *mut WasmStrList);
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi/src/preview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub mod bindings {

wasmtime::component::bindgen!({
path: "wit",
world: "wasi:cli/reactor",
world: "wasi:cli/imports",
tracing: true,
async: {
// Only these functions are `async` and everything else is sync
Expand Down
4 changes: 2 additions & 2 deletions crates/wasi/wit/command-extended.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// All of the same imports and exports available in the wasi:cli/command world
// with addition of HTTP proxy related imports:
world command-extended {
include wasi:cli/command@0.2.0-rc-2023-11-10;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-10;
include wasi:cli/command@0.2.0-rc-2023-12-05;
import wasi:http/outgoing-handler@0.2.0-rc-2023-12-05;
}
4 changes: 2 additions & 2 deletions crates/wasi/wit/deps/cli/command.wit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package wasi:cli@0.2.0-rc-2023-11-10;
package wasi:cli@0.2.0-rc-2023-12-05;

world command {
include reactor;
include imports;

export run;
}
20 changes: 20 additions & 0 deletions crates/wasi/wit/deps/cli/imports.wit
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package wasi:cli@0.2.0-rc-2023-12-05;

world imports {
include wasi:clocks/imports@0.2.0-rc-2023-11-10;
include wasi:filesystem/imports@0.2.0-rc-2023-11-10;
include wasi:sockets/imports@0.2.0-rc-2023-11-10;
include wasi:random/imports@0.2.0-rc-2023-11-10;
include wasi:io/imports@0.2.0-rc-2023-11-10;

import environment;
import exit;
import stdin;
import stdout;
import stderr;
import terminal-input;
import terminal-output;
import terminal-stdin;
import terminal-stdout;
import terminal-stderr;
}
31 changes: 0 additions & 31 deletions crates/wasi/wit/deps/cli/reactor.wit

This file was deleted.

11 changes: 5 additions & 6 deletions crates/wasi/wit/deps/http/proxy.wit
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
package wasi:http@0.2.0-rc-2023-11-10;
package wasi:http@0.2.0-rc-2023-12-05;

/// The `wasi:http/proxy` world captures a widely-implementable intersection of
/// hosts that includes HTTP forward and reverse proxies. Components targeting
/// this world may concurrently stream in and out any number of incoming and
/// outgoing HTTP requests.
world proxy {
/// HTTP proxies have access to time and randomness.
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10;
include wasi:clocks/imports@0.2.0-rc-2023-11-10;
import wasi:random/random@0.2.0-rc-2023-11-10;

/// Proxies have standard output and error streams which are expected to
/// terminate in a developer-facing console provided by the host.
import wasi:cli/stdout@0.2.0-rc-2023-11-10;
import wasi:cli/stderr@0.2.0-rc-2023-11-10;
import wasi:cli/stdout@0.2.0-rc-2023-12-05;
import wasi:cli/stderr@0.2.0-rc-2023-12-05;

/// TODO: this is a temporary workaround until component tooling is able to
/// gracefully handle the absence of stdin. Hosts must return an eof stream
/// for this import, which is what wasi-libc + tooling will do automatically
/// when this import is properly removed.
import wasi:cli/stdin@0.2.0-rc-2023-11-10;
import wasi:cli/stdin@0.2.0-rc-2023-12-05;

/// This is the default handler to use when user code simply wants to make an
/// HTTP request (e.g., via `fetch()`).
Expand Down
8 changes: 4 additions & 4 deletions crates/wasi/wit/test.wit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package wasmtime:wasi;

// only used as part of `test-programs`
world test-reactor {
include wasi:cli/reactor@0.2.0-rc-2023-11-10;
include wasi:cli/imports@0.2.0-rc-2023-12-05;

export add-strings: func(s: list<string>) -> u32;
export get-strings: func() -> list<string>;
Expand All @@ -16,7 +16,7 @@ world test-reactor {
}

world test-command {
include wasi:cli/reactor@0.2.0-rc-2023-11-10;
import wasi:http/types@0.2.0-rc-2023-11-10;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-10;
include wasi:cli/imports@0.2.0-rc-2023-12-05;
import wasi:http/types@0.2.0-rc-2023-12-05;
import wasi:http/outgoing-handler@0.2.0-rc-2023-12-05;
}
2 changes: 1 addition & 1 deletion tests/all/cli_tests/component-basic.wat
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
(func $run (result (result))
(canon lift (core func $i "run")))

(instance (export (interface "wasi:cli/[email protected]11-10"))
(instance (export (interface "wasi:cli/[email protected]12-05"))
(export "run" (func $run)))
)

0 comments on commit 759aa58

Please sign in to comment.