Browse Source

Gate logging in the C API on Cargo features (#7300)

Help to excise more dependencies when building the C API.
pull/7307/head
Alex Crichton 1 year ago
committed by GitHub
parent
commit
78e098db5a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Cargo.lock
  2. 21
      crates/c-api/Cargo.toml
  3. 1
      crates/c-api/src/engine.rs

2
Cargo.lock

@ -3327,7 +3327,9 @@ dependencies = [
"cap-std",
"env_logger 0.10.0",
"futures",
"log",
"once_cell",
"tracing",
"wasi-cap-std-sync",
"wasi-common",
"wasmtime",

21
crates/c-api/Cargo.toml

@ -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 }
@ -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
crates/c-api/src/engine.rs

@ -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 {

Loading…
Cancel
Save