File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -46,4 +46,14 @@ impl CfgOptions {
46
46
pub fn insert_key_value ( & mut self , key : SmolStr , value : SmolStr ) {
47
47
self . key_values . insert ( ( key, value) ) ;
48
48
}
49
+
50
+ pub fn append ( & mut self , other : & CfgOptions ) {
51
+ for atom in & other. atoms {
52
+ self . atoms . insert ( atom. clone ( ) ) ;
53
+ }
54
+
55
+ for ( key, value) in & other. key_values {
56
+ self . key_values . insert ( ( key. clone ( ) , value. clone ( ) ) ) ;
57
+ }
58
+ }
49
59
}
Original file line number Diff line number Diff line change @@ -246,6 +246,7 @@ impl ProjectWorkspace {
246
246
let mut crate_graph = CrateGraph :: default ( ) ;
247
247
match self {
248
248
ProjectWorkspace :: Json { project } => {
249
+ let mut target_cfg_map = FxHashMap :: < Option < & str > , CfgOptions > :: default ( ) ;
249
250
let crates: FxHashMap < _ , _ > = project
250
251
. crates
251
252
. iter ( )
@@ -265,6 +266,14 @@ impl ProjectWorkspace {
265
266
. proc_macro_dylib_path
266
267
. clone ( )
267
268
. map ( |it| proc_macro_client. by_dylib_path ( & it) ) ;
269
+
270
+ let target = krate. target . as_deref ( ) . or ( target) ;
271
+ let target_cfgs = target_cfg_map
272
+ . entry ( target. clone ( ) )
273
+ . or_insert_with ( || get_rustc_cfg_options ( target. as_deref ( ) ) ) ;
274
+ let mut cfg_options = krate. cfg . clone ( ) ;
275
+ cfg_options. append ( target_cfgs) ;
276
+
268
277
// FIXME: No crate name in json definition such that we cannot add OUT_DIR to env
269
278
Some ( (
270
279
CrateId ( seq_index as u32 ) ,
@@ -273,7 +282,7 @@ impl ProjectWorkspace {
273
282
krate. edition ,
274
283
// FIXME json definitions can store the crate name
275
284
None ,
276
- krate . cfg . clone ( ) ,
285
+ cfg_options ,
277
286
env,
278
287
proc_macro. unwrap_or_default ( ) ,
279
288
) ,
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ pub struct Crate {
31
31
pub ( crate ) edition : Edition ,
32
32
pub ( crate ) deps : Vec < Dependency > ,
33
33
pub ( crate ) cfg : CfgOptions ,
34
+ pub ( crate ) target : Option < String > ,
34
35
pub ( crate ) out_dir : Option < AbsPathBuf > ,
35
36
pub ( crate ) proc_macro_dylib_path : Option < AbsPathBuf > ,
36
37
}
@@ -65,6 +66,7 @@ impl ProjectJson {
65
66
}
66
67
cfg
67
68
} ,
69
+ target : crate_data. target ,
68
70
out_dir : crate_data. out_dir . map ( |it| base. join ( it) ) ,
69
71
proc_macro_dylib_path : crate_data. proc_macro_dylib_path . map ( |it| base. join ( it) ) ,
70
72
} )
@@ -86,6 +88,7 @@ struct CrateData {
86
88
deps : Vec < DepData > ,
87
89
#[ serde( default ) ]
88
90
cfg : FxHashSet < String > ,
91
+ target : Option < String > ,
89
92
out_dir : Option < PathBuf > ,
90
93
proc_macro_dylib_path : Option < PathBuf > ,
91
94
}
You can’t perform that action at this time.
0 commit comments