wiggle: allow disable tracing in Wiggle-generated code (#5146)

Wiggle generates code that instruments APIs with tracing code. This is
handy for diagnosing issues at runtime, but when inspecting the output
of Wiggle, it can make the generated code difficult for a human to
decipher. This change makes tracing a default but optional feature,
allowing users to avoid tracing code with commands like `cargo expand
--no-default-features`. This should be no change for current crates
depending on `wiggle`, `wiggle-macro`, and `wiggle-generate`.

review: add 'tracing' feature to wasi-common

review: switch to using macro configuration parsing

Co-authored-by: Andrew Brown <andrew.brown@intel.com>
This commit is contained in:
Pat Hickey
2022-10-27 11:26:54 -07:00
committed by GitHub
parent 3cbd490d52
commit 2702619427
5 changed files with 63 additions and 20 deletions

View File

@@ -12,6 +12,10 @@ pub struct CodegenSettings {
pub errors: ErrorTransform,
pub async_: AsyncConf,
pub wasmtime: bool,
// Disabling this feature makes it possible to remove all of the tracing
// code emitted in the Wiggle-generated code; this can be helpful while
// inspecting the code (e.g., with `cargo expand`).
pub tracing: bool,
}
impl CodegenSettings {
pub fn new(
@@ -19,12 +23,14 @@ impl CodegenSettings {
async_: &AsyncConf,
doc: &Document,
wasmtime: bool,
tracing: bool,
) -> Result<Self, Error> {
let errors = ErrorTransform::new(error_conf, doc)?;
Ok(Self {
errors,
async_: async_.clone(),
wasmtime,
tracing,
})
}
pub fn get_async(&self, module: &Module, func: &InterfaceFunc) -> Asyncness {