diff options
author | Paul Daniel Faria <[email protected]> | 2020-06-12 18:08:51 +0100 |
---|---|---|
committer | Paul Daniel Faria <[email protected]> | 2020-07-04 18:49:44 +0100 |
commit | db99f2dd7e8e244b858926bbf1d2a49e25f44733 (patch) | |
tree | 8c57a0a494e1a6e6250b5081276f57e8467a92cd /crates/ra_project_model/src/lib.rs | |
parent | c815d5b49660e9b93c6a70039abef5fa02ae8013 (diff) |
Add optional target to crates in json project, lookup default cfgs per target when generating cfg list
Diffstat (limited to 'crates/ra_project_model/src/lib.rs')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 464c3b2e3..4b50b9b69 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -246,6 +246,7 @@ impl ProjectWorkspace { | |||
246 | let mut crate_graph = CrateGraph::default(); | 246 | let mut crate_graph = CrateGraph::default(); |
247 | match self { | 247 | match self { |
248 | ProjectWorkspace::Json { project } => { | 248 | ProjectWorkspace::Json { project } => { |
249 | let mut target_cfg_map = FxHashMap::<Option<&str>, CfgOptions>::default(); | ||
249 | let crates: FxHashMap<_, _> = project | 250 | let crates: FxHashMap<_, _> = project |
250 | .crates | 251 | .crates |
251 | .iter() | 252 | .iter() |
@@ -265,6 +266,14 @@ impl ProjectWorkspace { | |||
265 | .proc_macro_dylib_path | 266 | .proc_macro_dylib_path |
266 | .clone() | 267 | .clone() |
267 | .map(|it| proc_macro_client.by_dylib_path(&it)); | 268 | .map(|it| proc_macro_client.by_dylib_path(&it)); |
269 | |||
270 | let target = krate.target.as_deref(); | ||
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 | // FIXME: No crate name in json definition such that we cannot add OUT_DIR to env | 277 | // FIXME: No crate name in json definition such that we cannot add OUT_DIR to env |
269 | Some(( | 278 | Some(( |
270 | CrateId(seq_index as u32), | 279 | CrateId(seq_index as u32), |
@@ -273,7 +282,7 @@ impl ProjectWorkspace { | |||
273 | krate.edition, | 282 | krate.edition, |
274 | // FIXME json definitions can store the crate name | 283 | // FIXME json definitions can store the crate name |
275 | None, | 284 | None, |
276 | krate.cfg.clone(), | 285 | cfg_options, |
277 | env, | 286 | env, |
278 | proc_macro.unwrap_or_default(), | 287 | proc_macro.unwrap_or_default(), |
279 | ), | 288 | ), |