Closed jice-nospam closed 6 years ago
Same for me - and the "debug_mgs" feature is definitely not being passed to rustc
when I check with --verbose
. Works fine with code in rhai examples folder, which is curious.
Aye, I will investigate this as well. Who knows? Maybe we found a bug in Cargo!
yeah, or possibly in nightly rustc. Right now, I have the opposite behavior : I have the debug_msgs feature enabled, but no messages, even after cargo clean
...
Right - things just got interesting. If I create a Cargo project with a path reference to the cloned Rhai repo, then happiness - no debug output! I change that to "0.8.1" and I get the output that I did not ask for! So the question is, what changes in the repo since last release? (I'm on stable). Perhaps all we need is a 0.8.2 release?
To answer this question - I note 0.8.1 was on 21st Dec. The last merge on 2nd March seems to be crucial here:
diff --git a/Cargo.toml b/Cargo.toml
index 1a7eef7..16bdba5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,3 +12,6 @@ include = [
"scripts/*.rhai",
"Cargo.toml"
]
+
+[features]
+debug_msgs = []
diff --git a/src/engine.rs b/src/engine.rs
index a00fbc2..4b6438d 100644
--- a/src/engine.rs
+++ b/src/engine.rs
@@ -160,7 +160,7 @@ impl Engine {
ident: String,
args: Vec<&mut Any>,
) -> Result<Box<Any>, EvalAltResult> {
- println!(
+ debug_println!(
"Trying to call function {:?} with args {:?}",
ident,
args.iter().map(|x| (&**x).type_id()).collect::<Vec<_>>()
@@ -196,7 +196,7 @@ impl Engine {
}
pub fn register_fn_raw(&mut self, ident: String, args: Option<Vec<TypeId>>, f: Box<FnAny>) {
- println!("Register; {:?} with args {:?}", ident, args,);
+ debug_println!("Register; {:?} with args {:?}", ident, args);
let spec = FnSpec { ident, args };
diff --git a/src/lib.rs b/src/lib.rs
index f03ff9d..14bc19a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -34,6 +34,13 @@
#![allow(warnings, unknown_lints, type_complexity, new_without_default_derive,
needless_pass_by_value, too_many_arguments)]
+// needs to be here, because order matters for macros
+macro_rules! debug_println {
+ () => (#[cfg(feature = "debug_msgs")] {print!("\n")});
+ ($fmt:expr) => (#[cfg(feature = "debug_msgs")] {print!(concat!($fmt, "\n"))});
+ ($fmt:expr, $($arg:tt)*) => (#[cfg(feature = "debug_msgs")] {print!(concat!($fmt, "\n"), $($arg)*)});
+}
+
Note that on 0.8.1 it was actually just println!
. So doing a 0.8.2 should solve our problem.
Ah, my bad, I had no idea I didn't publish a new version, haha. 0.8.2 is up now.
2018-03-27 10:07 GMT+02:00 Steve J Donovan notifications@github.com:
To answer this question - I note 0.8.1 was on 21st Dec. The last merge on 2nd March seems to be crucial here:
diff --git a/Cargo.toml b/Cargo.toml index 1a7eef7..16bdba5 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -12,3 +12,6 @@ include = [ "scripts/*.rhai", "Cargo.toml" ]++[features]+debug_msgs = []diff --git a/src/engine.rs b/src/engine.rs index a00fbc2..4b6438d 100644--- a/src/engine.rs+++ b/src/engine.rs@@ -160,7 +160,7 @@ impl Engine { ident: String, args: Vec<&mut Any>, ) -> Result<Box
, EvalAltResult> {- println!(+ debug_println!( "Trying to call function {:?} with args {:?}", ident, args.iter().map(|x| (&**x).typeid()).collect::<Vec<>>()@@ -196,7 +196,7 @@ impl Engine { } pub fn register_fn_raw(&mut self, ident: String, args: Option<Vec<TypeId>>, f: Box<FnAny>) {- println!("Register; {:?} with args {:?}", ident, args,);+ debug_println!("Register; {:?} with args {:?}", ident, args); let spec = FnSpec { ident, args };
diff --git a/src/lib.rs b/src/lib.rs index f03ff9d..14bc19a 100644--- a/src/lib.rs+++ b/src/lib.rs@@ -34,6 +34,13 @@
![allow(warnings, unknown_lints, type_complexity, new_without_default_derive,
needless_pass_by_value, too_many_arguments)]
+// needs to be here, because order matters for macros+macro_rules! debug_println {+ () => (#[cfg(feature = "debug_msgs")] {print!("\n")});+ ($fmt:expr) => (#[cfg(feature = "debug_msgs")] {print!(concat!($fmt, "\n"))});+ ($fmt:expr, $($arg:tt)) => (#[cfg(feature = "debug_msgs")] {print!(concat!($fmt, "\n"), $($arg))});+}+
Note that on 0.8.1 it was actually just println!. So doing a 0.8.2 should solve our problem.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jonathandturner/rhai/issues/65#issuecomment-376434620, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAzhxWwsksm1-jrbvgPbSkf9xqvTO2rks5tifM1gaJpZM4S5J7q .
Thanks man! 0.8.2 is indeed da bomb. By default, does not spew debug messages, and if I say features = ["debug_msgs"]
then I get the messages again. This is particularly cool because I've got a crate brewing that needs Rhai and now it can actually be published.
Confirmed! Works perfectly now. Thanks!
Glad I could help!
2018-03-28 11:22 GMT+02:00 jice-nospam notifications@github.com:
Confirmed! Works perfectly now. Thanks!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jonathandturner/rhai/issues/65#issuecomment-376820131, or mute the thread https://github.com/notifications/unsubscribe-auth/AIAzh-1U5F2F6wD9-APruzeGpvqjQsfRks5ti1ZQgaJpZM4S5J7q .
Is there a way to disable the debug_msgs feature when using the crate? I tried this
but I still get the messages