summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/libproc_macro/src/lib.rs31
-rw-r--r--src/expand/proc_macro.cpp4
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/libproc_macro/src/lib.rs b/lib/libproc_macro/src/lib.rs
index 7a3f1bdf..6de1140e 100644
--- a/lib/libproc_macro/src/lib.rs
+++ b/lib/libproc_macro/src/lib.rs
@@ -1,7 +1,26 @@
// MRustC custom version of libproc_macro
//
// Unlike the rustc version, this one is designed to live complely detached from its compiler.
-// See the
+
+//#[macro_use]
+//extern crate log;
+//extern crate env_logger;
+
+macro_rules! debug {
+ ( $($t:tt)* ) => {
+ if ::std::env::var_os("MRUSTC_PM_DEBUG").is_some() {
+ eprintln!($($t)*)
+ }
+ }
+}
+macro_rules! note {
+ ( $($t:tt)* ) => {
+ if ::std::env::var_os("MRUSTC_PM_DEBUG").is_some() {
+ eprintln!($($t)*)
+ }
+ }
+}
+
use std::fmt;
use std::str::FromStr;
@@ -646,6 +665,8 @@ pub struct MacroDesc
pub fn main(macros: &[MacroDesc])
{
+ //::env_logger::init();
+
let mac_name = ::std::env::args().nth(1).expect("Was not passed a macro name");
//eprintln!("Searching for macro {}\r", mac_name);
for m in macros
@@ -654,13 +675,13 @@ pub fn main(macros: &[MacroDesc])
use std::io::Write;
::std::io::stdout().write(&[0]);
::std::io::stdout().flush();
- //eprintln!("Waiting for input\r");
+ debug!("Waiting for input\r");
let input = recv_token_stream();
- //eprintln!("INPUT = `{}`\r", input);
+ debug!("INPUT = `{}`\r", input);
let output = (m.handler)( input );
- //eprintln!("OUTPUT = `{}`\r", output);
+ debug!("OUTPUT = `{}`\r", output);
send_token_stream(output);
- //eprintln!("Done");
+ note!("Done");
return ;
}
}
diff --git a/src/expand/proc_macro.cpp b/src/expand/proc_macro.cpp
index bd017e20..7752162c 100644
--- a/src/expand/proc_macro.cpp
+++ b/src/expand/proc_macro.cpp
@@ -741,8 +741,8 @@ ProcMacroInv::ProcMacroInv(const Span& sp, const char* executable, const char* m
posix_spawn_file_actions_addclose(&file_actions, stdout_pipes[1]);
char* argv[3] = { const_cast<char*>(executable), const_cast<char*>(macro_name), nullptr };
- char* envp[] = { nullptr };
- int rv = posix_spawn(&this->child_pid, executable, &file_actions, nullptr, argv, envp);
+ //char* envp[] = { nullptr };
+ int rv = posix_spawn(&this->child_pid, executable, &file_actions, nullptr, argv, environ);
if( rv != 0 )
{
BUG(sp, "Error in posix_spawn - " << rv);