Skip to content

Commit 08afa7b

Browse files
authored
Merge pull request #4 from alexcrichton/merge-main
Merge origin/main into resources branch
2 parents b76a61f + f175845 commit 08afa7b

File tree

35 files changed

+964
-259
lines changed

35 files changed

+964
-259
lines changed

Cargo.lock

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ serde_json = { workspace = true }
4848
wasmparser = { workspace = true }
4949
wasm-encoder = { workspace = true }
5050

51+
async-trait = { workspace = true }
52+
tokio = { workspace = true, optional = true, features = [ "signal", "macros" ] }
53+
hyper = { workspace = true, optional = true }
54+
http-body = { workspace = true }
55+
http-body-util = { workspace = true }
56+
5157
[target.'cfg(unix)'.dependencies]
5258
rustix = { workspace = true, features = ["mm", "param"] }
5359

@@ -60,7 +66,7 @@ filecheck = { workspace = true }
6066
tempfile = { workspace = true }
6167
test-programs = { path = "crates/test-programs" }
6268
wasmtime-runtime = { workspace = true }
63-
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
69+
tokio = { workspace = true, features = ["rt", "time", "macros", "rt-multi-thread"] }
6470
wast = { workspace = true }
6571
criterion = "0.5.0"
6672
num_cpus = "1.13.0"
@@ -101,6 +107,7 @@ members = [
101107
"crates/jit-icache-coherence",
102108
"crates/test-programs/wasi-tests",
103109
"crates/test-programs/wasi-http-tests",
110+
"crates/test-programs/wasi-http-proxy-tests",
104111
"crates/test-programs/wasi-sockets-tests",
105112
"crates/test-programs/command-tests",
106113
"crates/test-programs/reactor-tests",
@@ -251,7 +258,11 @@ tempfile = "3.1.0"
251258
filecheck = "0.5.0"
252259
libc = "0.2.60"
253260
file-per-thread-logger = "0.2.0"
254-
tokio = { version = "1.26.0" }
261+
tokio = { version = "1.26.0", features = [ "rt", "time" ] }
262+
hyper = "=1.0.0-rc.3"
263+
http = "0.2.9"
264+
http-body = "=1.0.0-rc.2"
265+
http-body-util = "=0.1.0-rc.2"
255266
bytes = "1.4"
256267
futures = { version = "0.3.27", default-features = false }
257268
indexmap = "2.0.0"
@@ -275,7 +286,7 @@ jitdump = ["wasmtime/jitdump"]
275286
vtune = ["wasmtime/vtune"]
276287
wasi-nn = ["dep:wasmtime-wasi-nn"]
277288
wasi-threads = ["dep:wasmtime-wasi-threads"]
278-
wasi-http = ["dep:wasmtime-wasi-http", "wasmtime-wasi-http?/sync"]
289+
wasi-http = ["component-model", "dep:wasmtime-wasi-http", "dep:tokio", "dep:hyper", "wasmtime-wasi-http?/sync"]
279290
pooling-allocator = ["wasmtime/pooling-allocator", "wasmtime-cli-flags/pooling-allocator"]
280291
all-arch = ["wasmtime/all-arch"]
281292
component-model = [
@@ -286,6 +297,9 @@ component-model = [
286297
winch = ["wasmtime/winch"]
287298
wmemcheck = ["wasmtime/wmemcheck"]
288299

300+
# Enable the `wasmtime serve` command
301+
serve = ["wasi-http", "component-model"]
302+
289303
[[test]]
290304
name = "host_segfault"
291305
harness = false

crates/c-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ publish = false
1111

1212
[lib]
1313
name = "wasmtime"
14-
crate-type = ["staticlib", "cdylib"]
14+
crate-type = ["staticlib", "cdylib", "rlib"]
1515
doc = false
1616
test = false
1717
doctest = false

crates/c-api/include/wasmtime/module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_module_deserialize_file(
158158
* For more details see: https://docs.wasmtime.dev/api/wasmtime/struct.Module.html#method.image_range
159159
*/
160160
WASM_API_EXTERN void wasmtime_module_image_range(
161-
const wasm_module_t *module,
161+
const wasmtime_module_t *module,
162162
size_t *start,
163163
size_t *end
164164
);

crates/c-api/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
1212
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
1313

14+
pub use wasmtime::*;
15+
1416
mod config;
1517
mod engine;
1618
mod error;

crates/environ/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ wasmprinter = { workspace = true, optional = true }
2828
wasmtime-component-util = { workspace = true, optional = true }
2929

3030
[dev-dependencies]
31-
atty = "0.2.14"
3231
clap = { workspace = true }
3332
env_logger = { workspace = true }
3433
wat = { workspace = true }

crates/environ/examples/factc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{bail, Context, Result};
22
use clap::Parser;
3-
use std::io::Write;
3+
use std::io::{IsTerminal, Write};
44
use std::path::PathBuf;
55
use wasmparser::{Validator, WasmFeatures};
66
use wasmtime_environ::component::*;
@@ -179,7 +179,7 @@ impl Factc {
179179
wasmprinter::print_bytes(&wasm)
180180
.context("failed to convert binary wasm to text")?
181181
.into_bytes()
182-
} else if self.output.is_none() && atty::is(atty::Stream::Stdout) {
182+
} else if self.output.is_none() && std::io::stdout().is_terminal() {
183183
bail!("cannot print binary wasm output to a terminal unless `-t` flag is passed")
184184
} else {
185185
wasm.clone()

crates/test-programs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ heck = { workspace = true }
1515

1616
[dependencies]
1717
anyhow = { workspace = true }
18+
bytes = { workspace = true }
1819
http = { version = "0.2.9" }
1920
http-body = "1.0.0-rc.2"
2021
http-body-util = "0.1.0-rc.2"
2122
hyper = { version = "1.0.0-rc.3", features = ["full"] }
22-
is-terminal = { workspace = true }
2323
tokio = { workspace = true, features = ["net", "rt-multi-thread", "macros"] }
2424
tracing = { workspace = true }
2525

crates/test-programs/build.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ fn build_and_generate_tests() {
3333
println!("cargo:rerun-if-changed=./wasi-sockets-tests");
3434
if BUILD_WASI_HTTP_TESTS {
3535
println!("cargo:rerun-if-changed=./wasi-http-tests");
36+
println!("cargo:rerun-if-changed=./wasi-http-proxy-tests");
3637
} else {
3738
println!("cargo:rustc-cfg=skip_wasi_http_tests");
3839
}
@@ -50,6 +51,7 @@ fn build_and_generate_tests() {
5051
.env_remove("CARGO_ENCODED_RUSTFLAGS");
5152
if BUILD_WASI_HTTP_TESTS {
5253
cmd.arg("--package=wasi-http-tests");
54+
cmd.arg("--package=wasi-http-proxy-tests");
5355
}
5456
let status = cmd.status().unwrap();
5557
assert!(status.success());
@@ -60,8 +62,14 @@ fn build_and_generate_tests() {
6062
components_rs(&meta, "wasi-tests", "bin", &command_adapter, &out_dir);
6163

6264
if BUILD_WASI_HTTP_TESTS {
63-
modules_rs(&meta, "wasi-http-tests", "bin", &out_dir);
6465
components_rs(&meta, "wasi-http-tests", "bin", &command_adapter, &out_dir);
66+
components_rs(
67+
&meta,
68+
"wasi-http-proxy-tests",
69+
"cdylib",
70+
&reactor_adapter,
71+
&out_dir,
72+
);
6573
}
6674

6775
components_rs(&meta, "command-tests", "bin", &command_adapter, &out_dir);

crates/test-programs/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
///! This crate exists to build crates for wasm32-wasi in build.rs, and execute
22
///! these wasm programs in harnesses defined under tests/.
3+
use std::io::IsTerminal;
34

45
#[cfg(all(feature = "test_programs", not(skip_wasi_http_tests)))]
56
pub mod http_server;
@@ -40,8 +41,7 @@ pub fn wasi_tests_environment() -> &'static [(&'static str, &'static str)] {
4041
}
4142

4243
pub fn stdio_is_terminal() -> bool {
43-
use is_terminal::is_terminal;
44-
is_terminal(&std::io::stdin())
45-
&& is_terminal(&std::io::stdout())
46-
&& is_terminal(&std::io::stderr())
44+
std::io::stdin().is_terminal()
45+
&& std::io::stdout().is_terminal()
46+
&& std::io::stderr().is_terminal()
4747
}

crates/test-programs/tests/wasi-http-components-sync.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use wasmtime::{
44
Config, Engine, Store,
55
};
66
use wasmtime_wasi::preview2::{
7-
command::sync::{add_to_linker, Command},
8-
pipe::MemoryOutputPipe,
9-
Table, WasiCtx, WasiCtxBuilder, WasiView,
7+
command::sync::Command, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder, WasiView,
108
};
119
use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};
1210

@@ -60,8 +58,7 @@ fn instantiate_component(
6058
ctx: Ctx,
6159
) -> Result<(Store<Ctx>, Command), anyhow::Error> {
6260
let mut linker = Linker::new(&ENGINE);
63-
add_to_linker(&mut linker)?;
64-
wasmtime_wasi_http::proxy::add_to_linker(&mut linker)?;
61+
wasmtime_wasi_http::proxy::sync::add_to_linker(&mut linker)?;
6562

6663
let mut store = Store::new(&ENGINE, ctx);
6764

crates/test-programs/tests/wasi-http-components.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use wasmtime::{
44
Config, Engine, Store,
55
};
66
use wasmtime_wasi::preview2::{
7-
command::{add_to_linker, Command},
8-
pipe::MemoryOutputPipe,
9-
Table, WasiCtx, WasiCtxBuilder, WasiView,
7+
command::Command, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder, WasiView,
108
};
119
use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};
1210

@@ -60,7 +58,6 @@ async fn instantiate_component(
6058
ctx: Ctx,
6159
) -> Result<(Store<Ctx>, Command), anyhow::Error> {
6260
let mut linker = Linker::new(&ENGINE);
63-
add_to_linker(&mut linker)?;
6461
wasmtime_wasi_http::proxy::add_to_linker(&mut linker)?;
6562

6663
let mut store = Store::new(&ENGINE, ctx);

0 commit comments

Comments
 (0)