From 0fe89051c7ee9ab753d50f5c0ea5d5dd1ccfa343 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Mon, 17 Mar 2014 13:08:00 -0700 Subject: [PATCH] Proxy output w/ color to tty --- src/bin/cargo-rustc.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/bin/cargo-rustc.rs b/src/bin/cargo-rustc.rs index fc42a7151..b6e516345 100644 --- a/src/bin/cargo-rustc.rs +++ b/src/bin/cargo-rustc.rs @@ -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 p = Process::new("rustc", args).unwrap(); - let o = p.wait_with_output(); + let mut config = ProcessConfig::new(); + config.stdout = InheritFd(1); + config.stderr = InheritFd(2); + config.program = "rustc"; + config.args = args.as_slice(); - if o.status == std::io::process::ExitStatus(0) { - println!("output: {:s}", std::str::from_utf8(o.output).unwrap()); - } else { + let mut p = Process::configure(config).unwrap(); + + let status = p.wait(); + + if status != std::io::process::ExitStatus(0) { fail!("Failed to execute") } }