From b0edbdcb846c66ec72f80b9dc86051bdcabb9caa Mon Sep 17 00:00:00 2001 From: F3real Date: Wed, 31 Aug 2016 23:32:59 +0200 Subject: [PATCH] Add recache support --- src/cache/cache.rs | 3 +++ src/compiler/compiler.rs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cache/cache.rs b/src/cache/cache.rs index 92c676043..eccda044c 100644 --- a/src/cache/cache.rs +++ b/src/cache/cache.rs @@ -43,6 +43,8 @@ pub enum Cache { Hit(CacheRead), /// Result was not found in cache. Miss, + /// Enviroment variable for recaching has been set + ReCache, } impl fmt::Debug for Cache { @@ -51,6 +53,7 @@ impl fmt::Debug for Cache { Cache::Error(ref e) => write!(f, "Cache::Error({:?}", e), Cache::Hit(_) => write!(f, "Cache::Hit(...)"), Cache::Miss => write!(f, "Cache::Miss"), + Cache::ReCache => write!(f, "Cache::ReCache"), } } } diff --git a/src/compiler/compiler.rs b/src/compiler/compiler.rs index ef6f189f6..68bb49e3b 100644 --- a/src/compiler/compiler.rs +++ b/src/compiler/compiler.rs @@ -32,6 +32,7 @@ use mock_command::{ }; use sha1; use std::collections::HashMap; +use std::env; use std::ffi::OsString; use std::fs::{self,File}; use std::io::prelude::*; @@ -226,7 +227,11 @@ impl Compiler { let outputs = parsed_args.outputs.iter() .map(|(key, path)| (key, pwd.join(path))) .collect::>(); - match storage.get(&key) { + let cache_status = match env::var("SCCACHE2_RECACHE"){ + Ok(_) => Cache::ReCache, + Err(_) => storage.get(&key) + }; + match cache_status { Cache::Hit(mut entry) => { debug!("Cache hit!"); for (key, path) in &outputs { @@ -244,9 +249,10 @@ impl Compiler { stderr: stderr.into_inner(), })) }, - res @ Cache::Miss | res @ Cache::Error(_) => { + res @ Cache::Miss | res @ Cache::ReCache | res @ Cache::Error(_) => { let cache_error = match res { Cache::Miss => { debug!("Cache miss!"); MissType::Normal } + Cache::ReCache => { debug!("Cache recache!"); MissType::Normal } Cache::Error(e) => { debug!("Cache read error: {:?}", e); MissType::CacheError