1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
14 use std::process::{self, Command};
17 let target = env::var("SCCACHE_TARGET").unwrap();
18 // Locate the actual compiler that we're invoking
19 env::set_var("CC", env::var_os("SCCACHE_CC").unwrap());
20 env::set_var("CXX", env::var_os("SCCACHE_CXX").unwrap());
21 let mut cfg = cc::Build::new();
22 cfg.cargo_metadata(false)
29 let compiler = cfg.get_compiler();
31 // Invoke sccache with said compiler
32 let sccache_path = env::var_os("SCCACHE_PATH").unwrap();
33 let mut cmd = Command::new(&sccache_path);
34 cmd.arg(compiler.path());
35 for &(ref k, ref v) in compiler.env() {
38 for arg in env::args().skip(1) {
42 if let Ok(s) = env::var("SCCACHE_EXTRA_ARGS") {
43 for s in s.split_whitespace() {
48 let status = cmd.status().expect("failed to spawn");
49 process::exit(status.code().unwrap_or(2))