Skip to content

Commit

Permalink
Use is-terminal instead of atty.
Browse files Browse the repository at this point in the history
Following up on bytecodealliance#3696, use the new is-terminal crate to test for a tty
rather than having platform-specific logic in Wasmtime. The is-terminal
crate has a platform-independent API which takes a handle.

This also updates the tree to cap-std 0.24 etc., to avoid depending on
multiple versions of io-lifetimes at once, as enforced by the cargo deny
check.
  • Loading branch information
sunfishcode authored and alexcrichton committed Feb 2, 2022
1 parent 700eca7 commit b5056a9
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 82 deletions.
85 changes: 53 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ wasmparser = "0.81.0"
lazy_static = "1.4.0"

[target.'cfg(unix)'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[dev-dependencies]
# depend again on wasmtime to activate its default features for tests
Expand Down
2 changes: 1 addition & 1 deletion crates/bench-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ wasmtime-wasi = { path = "../wasi" }
wasmtime-wasi-crypto = { path = "../wasi-crypto", optional = true }
wasmtime-wasi-nn = { path = "../wasi-nn", optional = true }
wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync" }
cap-std = "0.22.0"
cap-std = "0.24.0"

[dev-dependencies]
wat = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ wat = { version = "1.0.36", optional = true }
# Optional dependencies for the `wasi` feature
wasi-cap-std-sync = { path = "../wasi-common/cap-std-sync", optional = true }
wasmtime-wasi = { path = "../wasi", optional = true }
cap-std = { version = "0.22.0", optional = true }
cap-std = { version = "0.24.0", optional = true }

[features]
default = ['jitdump', 'wat', 'wasi', 'cache']
Expand Down
2 changes: 1 addition & 1 deletion crates/cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ zstd = { version = "0.9", default-features = false }
winapi = "0.3.7"

[target.'cfg(not(target_os = "windows"))'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[dev-dependencies]
filetime = "0.2.7"
Expand Down
2 changes: 1 addition & 1 deletion crates/fiber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ edition = "2018"
links = "wasmtime-fiber-shims"

[target.'cfg(unix)'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion crates/jit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ log = "0.4.8"
winapi = { version = "0.3.8", features = ["winnt", "impl-default"] }

[target.'cfg(target_os = "linux")'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[features]
jitdump = []
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ memfd = { version = "0.4.1", optional = true }
mach = "0.3.2"

[target.'cfg(unix)'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.7", features = ["winbase", "memoryapi", "errhandlingapi", "handleapi"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/test-programs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tempfile = "3.1.0"
os_pipe = "0.9"
anyhow = "1.0.19"
wat = "1.0.37"
cap-std = "0.22.0"
cap-std = "0.24.0"
tokio = { version = "1.8.0", features = ["rt-multi-thread"] }

[features]
Expand Down
6 changes: 3 additions & 3 deletions crates/wasi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ anyhow = "1.0"
thiserror = "1.0"
wiggle = { path = "../wiggle", default-features = false, version = "=0.33.0" }
tracing = "0.1.19"
cap-std = "0.22.0"
cap-rand = "0.22.0"
cap-std = "0.24.0"
cap-rand = "0.24.0"
bitflags = "1.2"

[target.'cfg(unix)'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[target.'cfg(windows)'.dependencies]
winapi = "0.3"
Expand Down
20 changes: 10 additions & 10 deletions crates/wasi-common/cap-std-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ include = ["src/**/*", "README.md", "LICENSE" ]
wasi-common = { path = "../", version = "=0.33.0" }
async-trait = "0.1"
anyhow = "1.0"
cap-std = "0.22.0"
cap-fs-ext = "0.22.0"
cap-time-ext = "0.22.0"
cap-rand = "0.22.0"
fs-set-times = "0.14.1"
system-interface = { version = "0.17.0", features = ["cap_std_impls"] }
cap-std = "0.24.0"
cap-fs-ext = "0.24.0"
cap-time-ext = "0.24.0"
cap-rand = "0.24.0"
fs-set-times = "0.15.0"
system-interface = { version = "0.20.0", features = ["cap_std_impls"] }
tracing = "0.1.19"
io-lifetimes = { version = "0.4.4", default-features = false }
io-lifetimes = { version = "0.5.0", default-features = false }
is-terminal = "0.1.0"

[target.'cfg(unix)'.dependencies]
rustix = "0.31.0"
rustix = "0.33.0"

[target.'cfg(windows)'.dependencies]
winapi = "0.3"
lazy_static = "1.4"
atty = "0.2.14"
io-extras = "0.12.0"
io-extras = "0.13.0"

[dev-dependencies]
tempfile = "3.1.0"
10 changes: 2 additions & 8 deletions crates/wasi-common/cap-std-sync/src/file.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use cap_fs_ext::MetadataExt;
use fs_set_times::{SetTimes, SystemTimeSpec};
use is_terminal::IsTerminal;
use std::any::Any;
use std::convert::TryInto;
use std::io;
Expand Down Expand Up @@ -125,14 +126,7 @@ impl WasiFile for File {
Ok(self.0.num_ready_bytes()?)
}
fn isatty(&self) -> bool {
#[cfg(unix)]
{
rustix::io::isatty(&self.0)
}
#[cfg(windows)]
{
false
}
self.0.is_terminal()
}
async fn readable(&self) -> Result<(), Error> {
Err(Error::badf())
Expand Down
Loading

0 comments on commit b5056a9

Please sign in to comment.