mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Proxy output w/ color to tty
This commit is contained in:
parent
8acc481e4c
commit
0fe89051c7
@ -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")
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user