mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Start breaking up cargo-compile
This commit is contained in:
parent
2fd7aad710
commit
ff85524210
@ -2,11 +2,32 @@
|
|||||||
#![allow(deprecated_owned_vector)]
|
#![allow(deprecated_owned_vector)]
|
||||||
|
|
||||||
extern crate cargo;
|
extern crate cargo;
|
||||||
|
extern crate hammer;
|
||||||
|
extern crate serialize;
|
||||||
|
|
||||||
use cargo::ops::cargo_compile::compile;
|
use cargo::ops::cargo_compile::compile;
|
||||||
|
use cargo::{CargoResult,ToCargoError};
|
||||||
|
use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError};
|
||||||
|
use serialize::Decodable;
|
||||||
|
|
||||||
|
#[deriving(Eq,Clone,Decodable,Encodable)]
|
||||||
|
pub struct Options {
|
||||||
|
manifest_path: ~str
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FlagConfig for Options {}
|
||||||
|
|
||||||
|
fn flags<T: FlagConfig + Decodable<FlagDecoder, HammerError>>() -> CargoResult<T> {
|
||||||
|
let mut decoder = FlagDecoder::new::<T>(std::os::args().tail());
|
||||||
|
Decodable::decode(&mut decoder).to_cargo_error(|e: HammerError| e.message, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn execute() -> CargoResult<()> {
|
||||||
|
compile(try!(flags::<Options>()).manifest_path.as_slice())
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match compile() {
|
match execute() {
|
||||||
Err(io_error) => fail!("{}", io_error),
|
Err(io_error) => fail!("{}", io_error),
|
||||||
Ok(_) => return
|
Ok(_) => return
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
use std;
|
use std;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
use serialize::{Decodable};
|
use serialize::{Decodable};
|
||||||
use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError};
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig};
|
use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user