File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ pub struct Build {
118
118
warnings_into_errors : bool ,
119
119
warnings : Option < bool > ,
120
120
extra_warnings : Option < bool > ,
121
+ env_cache : Arc < Mutex < HashMap < String , Option < String > > > > ,
121
122
}
122
123
123
124
/// Represents the types of errors that may occur while using cc-rs.
@@ -322,6 +323,7 @@ impl Build {
322
323
warnings : None ,
323
324
extra_warnings : None ,
324
325
warnings_into_errors : false ,
326
+ env_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
325
327
}
326
328
}
327
329
@@ -1963,8 +1965,13 @@ impl Build {
1963
1965
}
1964
1966
1965
1967
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
+ }
1966
1972
let r = env:: var ( v) . ok ( ) ;
1967
1973
self . print ( & format ! ( "{} = {:?}" , v, r) ) ;
1974
+ cache. insert ( v. to_string ( ) , r. clone ( ) ) ;
1968
1975
r
1969
1976
}
1970
1977
You can’t perform that action at this time.
0 commit comments