Skip to content

Commit 1bdd249

Browse files
committed
Support emitting debug logs in rules_rust process wrapper.
1 parent 3d1856b commit 1bdd249

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

util/process_wrapper/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,19 @@ impl fmt::Display for ProcessWrapperError {
6161

6262
impl std::error::Error for ProcessWrapperError {}
6363

64+
macro_rules! log {
65+
($($arg:tt)*) => {
66+
if std::env::var("RULES_RUST_PROCESS_WRAPPER_DEBUG").is_ok() {
67+
eprintln!($($arg)*);
68+
}
69+
};
70+
}
71+
6472
fn main() -> Result<(), ProcessWrapperError> {
6573
let opts = options().map_err(|e| ProcessWrapperError(e.to_string()))?;
6674

67-
let mut child = Command::new(opts.executable)
75+
let mut command = Command::new(opts.executable);
76+
command
6877
.args(opts.child_arguments)
6978
.env_clear()
7079
.envs(opts.child_environment)
@@ -79,7 +88,9 @@ fn main() -> Result<(), ProcessWrapperError> {
7988
} else {
8089
Stdio::inherit()
8190
})
82-
.stderr(Stdio::piped())
91+
.stderr(Stdio::piped());
92+
log!("{:#?}", command);
93+
let mut child = command
8394
.spawn()
8495
.map_err(|e| ProcessWrapperError(format!("failed to spawn child process: {}", e)))?;
8596

0 commit comments

Comments
 (0)