Skip to content

Commit

Permalink
Gate logging in the C API on Cargo features (#7300)
Browse files Browse the repository at this point in the history
Help to excise more dependencies when building the C API.
  • Loading branch information
alexcrichton authored Oct 19, 2023
1 parent 11b6001 commit 78e098d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

21 changes: 18 additions & 3 deletions crates/c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ publish = false

[lib]
name = "wasmtime"
crate-type = ["staticlib", "cdylib", "rlib"]
crate-type = ["staticlib", "cdylib"]
doc = false
test = false
doctest = false

[dependencies]
env_logger = { workspace = true }
env_logger = { workspace = true, optional = true }
anyhow = { workspace = true }
once_cell = { workspace = true }
wasmtime = { workspace = true, features = ['cranelift'] }
wasmtime-c-api-macros = { path = "macros" }
log = { workspace = true }
tracing = { workspace = true }

# Optional dependency for the `wat2wasm` API
wat = { workspace = true, optional = true }
Expand All @@ -36,9 +38,22 @@ wasi-common = { workspace = true, optional = true }
futures = { workspace = true, optional = true }

[features]
default = ['profiling', 'wat', 'wasi', 'cache', 'parallel-compilation', 'async']
default = [
'profiling',
'wat',
'wasi',
'cache',
'parallel-compilation',
'async',
'coredump',
'addr2line',
]
async = ['wasmtime/async', 'futures']
profiling = ["wasmtime/profiling"]
cache = ["wasmtime/cache"]
parallel-compilation = ['wasmtime/parallel-compilation']
wasi = ['wasi-cap-std-sync', 'wasmtime-wasi', 'cap-std', 'wasi-common']
logging = ['dep:env_logger']
disable-logging = ["log/max_level_off", "tracing/max_level_off"]
coredump = ["wasmtime/coredump"]
addr2line = ["wasmtime/addr2line"]
1 change: 1 addition & 0 deletions crates/c-api/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub extern "C" fn wasm_engine_new() -> Box<wasm_engine_t> {
// Note that we `drop` the result here since this fails after the first
// initialization attempt. We don't mind that though because this function
// can be called multiple times, so we just ignore the result.
#[cfg(feature = "logging")]
drop(env_logger::try_init());

Box::new(wasm_engine_t {
Expand Down

0 comments on commit 78e098d

Please sign in to comment.