Proxy output w/ color to tty
authorCarl Lerche <me@carllerche.com>
Mon, 17 Mar 2014 20:08:00 +0000 (13:08 -0700)
committerCarl Lerche <me@carllerche.com>
Mon, 17 Mar 2014 20:08:00 +0000 (13:08 -0700)
src/bin/cargo-rustc.rs

index fc42a7151e86f142b2582377df1b19d74ed00e57..b6e516345c03863f69396efedb436ec083fdf609 100644 (file)
@@ -6,7 +6,7 @@ extern crate cargo;
 
 use std::os::args;
 use std::io;
-use std::io::process::Process;
+use std::io::process::{Process,ProcessConfig,InheritFd};
 use serialize::json;
 use serialize::Decodable;
 use std::path::Path;
@@ -26,22 +26,13 @@ fn main() {
     let mut decoder = json::Decoder::new(json);
     let manifest: Manifest = Decodable::decode(&mut decoder);
 
-    //let mut arguments = args();
-    //arguments.shift();
-
-    //if arguments[0] != ~"--" {
-        //fail!("LOL");
-    //} else {
-        //arguments.shift();
-    //}
-
     let Manifest{ root, lib, .. } = manifest;
 
     let root = Path::new(root);
     let out_dir = lib[0].path;
     let target = join(&root, ~"target");
 
-    let args = ~[
+    let args = [
         join(&root, out_dir),
         ~"--out-dir", target,
         ~"--crate-type", ~"lib"
@@ -52,14 +43,19 @@ fn main() {
         Ok(val) => val
     }
 
-    println!("Executing {}", args);
+    println!("Executing {}", args.as_slice());
+
+    let mut config = ProcessConfig::new();
+    config.stdout = InheritFd(1);
+    config.stderr = InheritFd(2);
+    config.program = "rustc";
+    config.args = args.as_slice();
+
+    let mut p = Process::configure(config).unwrap();
 
-    let mut p = Process::new("rustc", args).unwrap();
-    let o = p.wait_with_output();
+    let status = p.wait();
 
-    if o.status == std::io::process::ExitStatus(0) {
-        println!("output: {:s}", std::str::from_utf8(o.output).unwrap());
-    } else {
+    if status != std::io::process::ExitStatus(0) {
         fail!("Failed to execute")
     }
 }