From 948e685dd6d2551e28cd8af4e13d97190a449534 Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Mon, 28 Jan 2019 20:06:57 -0600 Subject: [PATCH] Consolidate to single debug macro, activate using feature --- lib/emscripten/src/macros.rs | 5 +---- lib/runtime-core/src/macros.rs | 13 +++++++++++-- src/lib.rs | 3 +-- src/macros.rs | 5 ----- 4 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 src/macros.rs diff --git a/lib/emscripten/src/macros.rs b/lib/emscripten/src/macros.rs index fe2bd1a7f..8b1378917 100644 --- a/lib/emscripten/src/macros.rs +++ b/lib/emscripten/src/macros.rs @@ -1,4 +1 @@ -macro_rules! debug { - ($fmt:expr) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("wasmer-runtime(:{})::", $fmt), line!()) }); - ($fmt:expr, $($arg:tt)*) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("wasmer-runtime(:{})::", $fmt, "\n"), line!(), $($arg)*) }); -} + diff --git a/lib/runtime-core/src/macros.rs b/lib/runtime-core/src/macros.rs index 80be85478..0a2d57afe 100644 --- a/lib/runtime-core/src/macros.rs +++ b/lib/runtime-core/src/macros.rs @@ -1,6 +1,15 @@ +#[macro_export] +#[cfg(feature = "debug")] macro_rules! debug { - ($fmt:expr) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("wasmer-runtime(:{})::", $fmt), line!()) }); - ($fmt:expr, $($arg:tt)*) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("wasmer-runtime(:{})::", $fmt, "\n"), line!(), $($arg)*) }); + ($fmt:expr) => (println!(concat!("wasmer-runtime(:{})::", $fmt), line!())); + ($fmt:expr, $($arg:tt)*) => (println!(concat!("wasmer-runtime(:{})::", $fmt, "\n"), line!(), $($arg)*)); +} + +#[macro_export] +#[cfg(not(feature = "debug"))] +macro_rules! debug { + ($fmt:expr) => {}; + ($fmt:expr, $($arg:tt)*) => {}; } #[macro_export] diff --git a/src/lib.rs b/src/lib.rs index 0a177d348..8022c6eab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,7 @@ +#[macro_use] extern crate wasmer_runtime_core; // extern crate wasmer_emscripten; -#[macro_use] -mod macros; #[macro_use] pub mod update; pub mod webassembly; diff --git a/src/macros.rs b/src/macros.rs deleted file mode 100644 index f69d2dca5..000000000 --- a/src/macros.rs +++ /dev/null @@ -1,5 +0,0 @@ -#[macro_export] -macro_rules! debug { - ($fmt:expr) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("Wasmer::", $fmt)) }); - ($fmt:expr, $($arg:tt)*) => (if cfg!(any(debug_assertions, feature="debug")) { println!(concat!("Wasmer::", $fmt, "\n"), $($arg)*) }); -}