diff options
author | Edwin Cheng <[email protected]> | 2020-03-11 03:04:02 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-11 03:04:02 +0000 |
commit | 6ea7c319154f9ec10721f4041afc9d07d6b2476b (patch) | |
tree | bdd64414df9950213cc117e2975d8fd17f85fbfc /crates/ra_project_model/src | |
parent | 5a292309c55639a12d10b3c37b9f800d8b802b6d (diff) |
Add extern source
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index b46320304..a6274709d 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -14,7 +14,7 @@ use std::{ | |||
14 | 14 | ||
15 | use anyhow::{bail, Context, Result}; | 15 | use anyhow::{bail, Context, Result}; |
16 | use ra_cfg::CfgOptions; | 16 | use ra_cfg::CfgOptions; |
17 | use ra_db::{CrateGraph, CrateName, Edition, Env, ExternSourceId, FileId}; | 17 | use ra_db::{CrateGraph, CrateName, Edition, Env, ExternSource, ExternSourceId, FileId}; |
18 | use rustc_hash::FxHashMap; | 18 | use rustc_hash::FxHashMap; |
19 | use serde_json::from_reader; | 19 | use serde_json::from_reader; |
20 | 20 | ||
@@ -197,6 +197,7 @@ impl ProjectWorkspace { | |||
197 | None, | 197 | None, |
198 | cfg_options, | 198 | cfg_options, |
199 | Env::default(), | 199 | Env::default(), |
200 | Default::default(), | ||
200 | ), | 201 | ), |
201 | ); | 202 | ); |
202 | } | 203 | } |
@@ -235,8 +236,10 @@ impl ProjectWorkspace { | |||
235 | }; | 236 | }; |
236 | 237 | ||
237 | let mut env = Env::default(); | 238 | let mut env = Env::default(); |
239 | let mut extern_source = ExternSource::default(); | ||
238 | if let Some((id, path)) = outdirs.get(krate.name(&sysroot)) { | 240 | if let Some((id, path)) = outdirs.get(krate.name(&sysroot)) { |
239 | env.set_extern_path("OUT_DIR", &path, *id); | 241 | env.set("OUT_DIR", path.clone()); |
242 | extern_source.set_extern_path(&path, *id); | ||
240 | } | 243 | } |
241 | 244 | ||
242 | let crate_id = crate_graph.add_crate_root( | 245 | let crate_id = crate_graph.add_crate_root( |
@@ -245,6 +248,7 @@ impl ProjectWorkspace { | |||
245 | Some(krate.name(&sysroot).to_string()), | 248 | Some(krate.name(&sysroot).to_string()), |
246 | cfg_options, | 249 | cfg_options, |
247 | env, | 250 | env, |
251 | extern_source, | ||
248 | ); | 252 | ); |
249 | sysroot_crates.insert(krate, crate_id); | 253 | sysroot_crates.insert(krate, crate_id); |
250 | } | 254 | } |
@@ -284,8 +288,10 @@ impl ProjectWorkspace { | |||
284 | opts | 288 | opts |
285 | }; | 289 | }; |
286 | let mut env = Env::default(); | 290 | let mut env = Env::default(); |
291 | let mut extern_source = ExternSource::default(); | ||
287 | if let Some((id, path)) = outdirs.get(pkg.name(&cargo)) { | 292 | if let Some((id, path)) = outdirs.get(pkg.name(&cargo)) { |
288 | env.set_extern_path("OUT_DIR", &path, *id); | 293 | env.set("OUT_DIR", path.clone()); |
294 | extern_source.set_extern_path(&path, *id); | ||
289 | } | 295 | } |
290 | let crate_id = crate_graph.add_crate_root( | 296 | let crate_id = crate_graph.add_crate_root( |
291 | file_id, | 297 | file_id, |
@@ -293,6 +299,7 @@ impl ProjectWorkspace { | |||
293 | Some(pkg.name(&cargo).to_string()), | 299 | Some(pkg.name(&cargo).to_string()), |
294 | cfg_options, | 300 | cfg_options, |
295 | env, | 301 | env, |
302 | extern_source, | ||
296 | ); | 303 | ); |
297 | if tgt.kind(&cargo) == TargetKind::Lib { | 304 | if tgt.kind(&cargo) == TargetKind::Lib { |
298 | lib_tgt = Some(crate_id); | 305 | lib_tgt = Some(crate_id); |