Skip to content

Commit

Permalink
Change getenv to only emit metadata once per var
Browse files Browse the repository at this point in the history
  • Loading branch information
nathaniel-daniel authored and thomcc committed Oct 29, 2022
1 parent 765f486 commit 0b25dbf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2854,13 +2854,13 @@ impl Build {
}

fn getenv(&self, v: &str) -> Option<String> {
if self.emit_rerun_if_env_changed {
self.print(&format!("cargo:rerun-if-env-changed={}", v));
}
let mut cache = self.env_cache.lock().unwrap();
if let Some(val) = cache.get(v) {
return val.clone();
}
if self.emit_rerun_if_env_changed {
self.print(&format!("cargo:rerun-if-env-changed={}", v));
}
let r = env::var(v).ok();
self.print(&format!("{} = {:?}", v, r));
cache.insert(v.to_string(), r.clone());
Expand Down

0 comments on commit 0b25dbf

Please sign in to comment.