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 {
4646 pub fn insert_key_value ( & mut self , key : SmolStr , value : SmolStr ) {
4747 self . key_values . insert ( ( key, value) ) ;
4848 }
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+ }
4959}
Original file line number Diff line number Diff line change @@ -246,6 +246,7 @@ impl ProjectWorkspace {
246246 let mut crate_graph = CrateGraph :: default ( ) ;
247247 match self {
248248 ProjectWorkspace :: Json { project } => {
249+ let mut target_cfg_map = FxHashMap :: < Option < & str > , CfgOptions > :: default ( ) ;
249250 let crates: FxHashMap < _ , _ > = project
250251 . crates
251252 . iter ( )
@@ -265,6 +266,14 @@ impl ProjectWorkspace {
265266 . proc_macro_dylib_path
266267 . clone ( )
267268 . 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+
268277 // FIXME: No crate name in json definition such that we cannot add OUT_DIR to env
269278 Some ( (
270279 CrateId ( seq_index as u32 ) ,
@@ -273,7 +282,7 @@ impl ProjectWorkspace {
273282 krate. edition ,
274283 // FIXME json definitions can store the crate name
275284 None ,
276- krate . cfg . clone ( ) ,
285+ cfg_options ,
277286 env,
278287 proc_macro. unwrap_or_default ( ) ,
279288 ) ,
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ pub struct Crate {
3131 pub ( crate ) edition : Edition ,
3232 pub ( crate ) deps : Vec < Dependency > ,
3333 pub ( crate ) cfg : CfgOptions ,
34+ pub ( crate ) target : Option < String > ,
3435 pub ( crate ) out_dir : Option < AbsPathBuf > ,
3536 pub ( crate ) proc_macro_dylib_path : Option < AbsPathBuf > ,
3637}
@@ -65,6 +66,7 @@ impl ProjectJson {
6566 }
6667 cfg
6768 } ,
69+ target : crate_data. target ,
6870 out_dir : crate_data. out_dir . map ( |it| base. join ( it) ) ,
6971 proc_macro_dylib_path : crate_data. proc_macro_dylib_path . map ( |it| base. join ( it) ) ,
7072 } )
@@ -86,6 +88,7 @@ struct CrateData {
8688 deps : Vec < DepData > ,
8789 #[ serde( default ) ]
8890 cfg : FxHashSet < String > ,
91+ target : Option < String > ,
8992 out_dir : Option < PathBuf > ,
9093 proc_macro_dylib_path : Option < PathBuf > ,
9194}
You can’t perform that action at this time.
0 commit comments