File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ pub struct Build {
118118 warnings_into_errors : bool ,
119119 warnings : Option < bool > ,
120120 extra_warnings : Option < bool > ,
121+ env_cache : Arc < Mutex < HashMap < String , Option < String > > > > ,
121122}
122123
123124/// Represents the types of errors that may occur while using cc-rs.
@@ -322,6 +323,7 @@ impl Build {
322323 warnings : None ,
323324 extra_warnings : None ,
324325 warnings_into_errors : false ,
326+ env_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
325327 }
326328 }
327329
@@ -1963,8 +1965,13 @@ impl Build {
19631965 }
19641966
19651967 fn getenv ( & self , v : & str ) -> Option < String > {
1968+ let mut cache = self . env_cache . lock ( ) . unwrap ( ) ;
1969+ if let Some ( val) = cache. get ( v) {
1970+ return val. clone ( )
1971+ }
19661972 let r = env:: var ( v) . ok ( ) ;
19671973 self . print ( & format ! ( "{} = {:?}" , v, r) ) ;
1974+ cache. insert ( v. to_string ( ) , r. clone ( ) ) ;
19681975 r
19691976 }
19701977
You can’t perform that action at this time.
0 commit comments