aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r--crates/ra_project_model/src/lib.rs11
-rw-r--r--crates/ra_project_model/src/project_json.rs3
2 files changed, 13 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 ),
diff --git a/crates/ra_project_model/src/project_json.rs b/crates/ra_project_model/src/project_json.rs
index b0fe09333..b96227949 100644
--- a/crates/ra_project_model/src/project_json.rs
+++ b/crates/ra_project_model/src/project_json.rs
@@ -31,6 +31,7 @@ pub struct Crate {
31 pub(crate) edition: Edition, 31 pub(crate) edition: Edition,
32 pub(crate) deps: Vec<Dependency>, 32 pub(crate) deps: Vec<Dependency>,
33 pub(crate) cfg: CfgOptions, 33 pub(crate) cfg: CfgOptions,
34 pub(crate) target: Option<String>,
34 pub(crate) out_dir: Option<AbsPathBuf>, 35 pub(crate) out_dir: Option<AbsPathBuf>,
35 pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>, 36 pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>,
36} 37}
@@ -65,6 +66,7 @@ impl ProjectJson {
65 } 66 }
66 cfg 67 cfg
67 }, 68 },
69 target: crate_data.target,
68 out_dir: crate_data.out_dir.map(|it| base.join(it)), 70 out_dir: crate_data.out_dir.map(|it| base.join(it)),
69 proc_macro_dylib_path: crate_data.proc_macro_dylib_path.map(|it| base.join(it)), 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 deps: Vec<DepData>, 88 deps: Vec<DepData>,
87 #[serde(default)] 89 #[serde(default)]
88 cfg: FxHashSet<String>, 90 cfg: FxHashSet<String>,
91 target: Option<String>,
89 out_dir: Option<PathBuf>, 92 out_dir: Option<PathBuf>,
90 proc_macro_dylib_path: Option<PathBuf>, 93 proc_macro_dylib_path: Option<PathBuf>,
91} 94}