Skip to content

Commit

Permalink
Make wasmtime dependency in wiggle and wasi-common optional with a de…
Browse files Browse the repository at this point in the history
…fault feature (#7792)

* Make wasmtime dependency in wiggle and wasi-common optional with a default feature

* Use wiggle/wasmtime feature in wasmtime-wasi
  • Loading branch information
juntyr authored Jan 18, 2024
1 parent 2c86e26 commit e5817d9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ component-fuzz-util = { path = "crates/misc/component-fuzz-util" }
wiggle = { path = "crates/wiggle", version = "=18.0.0", default-features = false }
wiggle-macro = { path = "crates/wiggle/macro", version = "=18.0.0" }
wiggle-generate = { path = "crates/wiggle/generate", version = "=18.0.0" }
wasi-common = { path = "crates/wasi-common", version = "=18.0.0" }
wasi-common = { path = "crates/wasi-common", version = "=18.0.0", default-features = false }
wasi-tokio = { path = "crates/wasi-common/tokio", version = "=18.0.0" }
wasi-cap-std-sync = { path = "crates/wasi-common/cap-std-sync", version = "=18.0.0" }
wasmtime-fuzzing = { path = "crates/fuzzing" }
Expand Down
6 changes: 4 additions & 2 deletions crates/wasi-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ workspace = true
anyhow = { workspace = true }
thiserror = { workspace = true }
wiggle = { workspace = true }
wasmtime = { workspace = true }
wasmtime = { workspace = true, optional = true }
tracing = { workspace = true }
cap-std = { workspace = true }
cap-rand = { workspace = true }
Expand Down Expand Up @@ -54,11 +54,13 @@ test-programs-artifacts = { workspace = true }
tokio = { workspace = true, features = ['macros', 'rt-multi-thread'] }

[features]
default = ["trace_log"]
default = ["trace_log", "wasmtime"]
# This feature enables the `tracing` logs in the calls to target the `log`
# ecosystem of backends (e.g. `env_logger`. Disable this if you want to use
# `tracing-subscriber`.
trace_log = [ "wiggle/tracing_log", "tracing/log" ]
# Need to make the wiggle_metadata feature available to consumers of this
# crate if they want the snapshots to have metadata available.
wiggle_metadata = ["wiggle/wiggle_metadata"]
# This feature enables integration with wasmtime.
wasmtime = ["dep:wasmtime", "wiggle/wasmtime"]
2 changes: 1 addition & 1 deletion crates/wasi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ anyhow = { workspace = true }
wasi-common = { workspace = true }
wasi-cap-std-sync = { workspace = true, optional = true }
wasi-tokio = { workspace = true, optional = true }
wiggle = { workspace = true, optional = true }
wiggle = { workspace = true, optional = true, features = ["wasmtime"] }
libc = { workspace = true }
once_cell = { workspace = true }
log = { workspace = true }
Expand Down
8 changes: 6 additions & 2 deletions crates/wiggle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ wiggle-macro = { workspace = true }
tracing = { workspace = true }
bitflags = { workspace = true }
async-trait = { workspace = true }
wasmtime = { workspace = true }
wasmtime = { workspace = true, optional = true }
anyhow = { workspace = true }

[dev-dependencies]
wiggle-test = { path = "test-helpers" }
proptest = "1.0.0"
tokio = { version = "1", features = ["rt-multi-thread","time", "macros"] }
wasmtime = { workspace = true }

[[test]]
name = "atoms_async"
Expand Down Expand Up @@ -62,7 +63,10 @@ wiggle_metadata = ['witx', "wiggle-macro/wiggle_metadata"]
# the logs out of wiggle-generated libraries.
tracing_log = [ "tracing/log" ]

# This feature enables integration with wasmtime.
wasmtime = ["dep:wasmtime"]

# Support for async in the wasmtime crates.
wasmtime_async = [ "wasmtime/async" ]

default = ["wiggle_metadata", "wasmtime_async" ]
default = ["wiggle_metadata", "wasmtime", "wasmtime_async" ]
1 change: 1 addition & 0 deletions crates/wiggle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub mod async_trait_crate {
}

pub mod wasmtime;
#[cfg(feature = "wasmtime")]
pub mod wasmtime_crate {
pub use wasmtime::*;
}
Expand Down

0 comments on commit e5817d9

Please sign in to comment.