@@ -88,6 +88,7 @@ pub struct PackageData {
88
88
pub edition : Edition ,
89
89
pub features : Vec < String > ,
90
90
pub cfgs : Vec < CfgFlag > ,
91
+ pub envs : Vec < ( String , String ) > ,
91
92
pub out_dir : Option < AbsPathBuf > ,
92
93
pub proc_macro_dylib_path : Option < AbsPathBuf > ,
93
94
}
@@ -173,11 +174,13 @@ impl CargoWorkspace {
173
174
174
175
let mut out_dir_by_id = FxHashMap :: default ( ) ;
175
176
let mut cfgs = FxHashMap :: default ( ) ;
177
+ let mut envs = FxHashMap :: default ( ) ;
176
178
let mut proc_macro_dylib_paths = FxHashMap :: default ( ) ;
177
179
if config. load_out_dirs_from_check {
178
180
let resources = load_extern_resources ( cargo_toml, config) ?;
179
181
out_dir_by_id = resources. out_dirs ;
180
182
cfgs = resources. cfgs ;
183
+ envs = resources. env ;
181
184
proc_macro_dylib_paths = resources. proc_dylib_paths ;
182
185
}
183
186
@@ -205,6 +208,7 @@ impl CargoWorkspace {
205
208
dependencies : Vec :: new ( ) ,
206
209
features : Vec :: new ( ) ,
207
210
cfgs : cfgs. get ( & id) . cloned ( ) . unwrap_or_default ( ) ,
211
+ envs : envs. get ( & id) . cloned ( ) . unwrap_or_default ( ) ,
208
212
out_dir : out_dir_by_id. get ( & id) . cloned ( ) ,
209
213
proc_macro_dylib_path : proc_macro_dylib_paths. get ( & id) . cloned ( ) ,
210
214
} ) ;
@@ -289,6 +293,7 @@ pub(crate) struct ExternResources {
289
293
out_dirs : FxHashMap < PackageId , AbsPathBuf > ,
290
294
proc_dylib_paths : FxHashMap < PackageId , AbsPathBuf > ,
291
295
cfgs : FxHashMap < PackageId , Vec < CfgFlag > > ,
296
+ env : FxHashMap < PackageId , Vec < ( String , String ) > > ,
292
297
}
293
298
294
299
pub ( crate ) fn load_extern_resources (
@@ -323,7 +328,13 @@ pub(crate) fn load_extern_resources(
323
328
for message in cargo_metadata:: Message :: parse_stream ( output. stdout . as_slice ( ) ) {
324
329
if let Ok ( message) = message {
325
330
match message {
326
- Message :: BuildScriptExecuted ( BuildScript { package_id, out_dir, cfgs, .. } ) => {
331
+ Message :: BuildScriptExecuted ( BuildScript {
332
+ package_id,
333
+ out_dir,
334
+ cfgs,
335
+ env,
336
+ ..
337
+ } ) => {
327
338
let cfgs = {
328
339
let mut acc = Vec :: new ( ) ;
329
340
for cfg in cfgs {
@@ -341,8 +352,10 @@ pub(crate) fn load_extern_resources(
341
352
if out_dir != PathBuf :: default ( ) {
342
353
let out_dir = AbsPathBuf :: assert ( out_dir) ;
343
354
res. out_dirs . insert ( package_id. clone ( ) , out_dir) ;
344
- res. cfgs . insert ( package_id, cfgs) ;
355
+ res. cfgs . insert ( package_id. clone ( ) , cfgs) ;
345
356
}
357
+
358
+ res. env . insert ( package_id, env) ;
346
359
}
347
360
Message :: CompilerArtifact ( message) => {
348
361
if message. target . kind . contains ( & "proc-macro" . to_string ( ) ) {
0 commit comments