Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add recache support #24

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"),
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -226,7 +227,11 @@ impl Compiler {
let outputs = parsed_args.outputs.iter()
.map(|(key, path)| (key, pwd.join(path)))
.collect::<HashMap<_, _>>();
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 {
Expand All @@ -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
Expand Down