use std::process::Command; use std::path::Path; use std::process::exit; use std::fs; use std::env::vars; fn main() { let opt = vars().find(|s| &s.0 == &"CARGO_HOME"); let cargo_home = match opt { Some(home) => Path::new(&home.1).to_path_buf(), None => Path::new("~").join(".cargo"), }; let clippy_path = cargo_home.join("rust-clippy"); if clippy_path.exists() { Command::new("rm") .arg("-rf") .arg(&clippy_path) .output() .unwrap_or_else(|e| panic!("failed to remove rust-clippy: {}", e)); } fs::DirBuilder::new().recursive(true).create(&clippy_path).unwrap(); Command::new("git") .arg("clone") .arg("https://github.com/Manishearth/rust-clippy.git") .arg(&clippy_path) .output() .unwrap_or_else(|e| panic!("failed to clone: {}", e)); let mut child = Command::new("cargo") .arg("build") .arg("--release") .current_dir(&clippy_path) .spawn() .unwrap_or_else(|e| panic!("failed to build: {}", e)); let exit_status = child.wait().unwrap_or_else(|e| panic!("{}", e)); if let Some(code) = exit_status.code() { exit(code); } }