diff options
Diffstat (limited to 'crates/ra_project_model/src/cargo_workspace.rs')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index eb9f33ee8..a306ce95f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -11,7 +11,6 @@ use anyhow::{Context, Result}; | |||
11 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; | 11 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; |
12 | use ra_arena::{Arena, Idx}; | 12 | use ra_arena::{Arena, Idx}; |
13 | use ra_db::Edition; | 13 | use ra_db::Edition; |
14 | use ra_env::get_path_for_executable; | ||
15 | use rustc_hash::FxHashMap; | 14 | use rustc_hash::FxHashMap; |
16 | 15 | ||
17 | /// `CargoWorkspace` represents the logical structure of, well, a Cargo | 16 | /// `CargoWorkspace` represents the logical structure of, well, a Cargo |
@@ -147,7 +146,7 @@ impl CargoWorkspace { | |||
147 | cargo_features: &CargoConfig, | 146 | cargo_features: &CargoConfig, |
148 | ) -> Result<CargoWorkspace> { | 147 | ) -> Result<CargoWorkspace> { |
149 | let mut meta = MetadataCommand::new(); | 148 | let mut meta = MetadataCommand::new(); |
150 | meta.cargo_path(get_path_for_executable("cargo")?); | 149 | meta.cargo_path(ra_toolchain::cargo()); |
151 | meta.manifest_path(cargo_toml); | 150 | meta.manifest_path(cargo_toml); |
152 | if cargo_features.all_features { | 151 | if cargo_features.all_features { |
153 | meta.features(CargoOpt::AllFeatures); | 152 | meta.features(CargoOpt::AllFeatures); |
@@ -162,7 +161,7 @@ impl CargoWorkspace { | |||
162 | meta.current_dir(parent); | 161 | meta.current_dir(parent); |
163 | } | 162 | } |
164 | if let Some(target) = cargo_features.target.as_ref() { | 163 | if let Some(target) = cargo_features.target.as_ref() { |
165 | meta.other_options(&[String::from("--filter-platform"), target.clone()]); | 164 | meta.other_options(vec![String::from("--filter-platform"), target.clone()]); |
166 | } | 165 | } |
167 | let meta = meta.exec().with_context(|| { | 166 | let meta = meta.exec().with_context(|| { |
168 | format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) | 167 | format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) |
@@ -289,7 +288,7 @@ pub fn load_extern_resources( | |||
289 | cargo_toml: &Path, | 288 | cargo_toml: &Path, |
290 | cargo_features: &CargoConfig, | 289 | cargo_features: &CargoConfig, |
291 | ) -> Result<ExternResources> { | 290 | ) -> Result<ExternResources> { |
292 | let mut cmd = Command::new(get_path_for_executable("cargo")?); | 291 | let mut cmd = Command::new(ra_toolchain::cargo()); |
293 | cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); | 292 | cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); |
294 | if cargo_features.all_features { | 293 | if cargo_features.all_features { |
295 | cmd.arg("--all-features"); | 294 | cmd.arg("--all-features"); |
@@ -305,19 +304,13 @@ pub fn load_extern_resources( | |||
305 | 304 | ||
306 | let mut res = ExternResources::default(); | 305 | let mut res = ExternResources::default(); |
307 | 306 | ||
308 | for message in cargo_metadata::parse_messages(output.stdout.as_slice()) { | 307 | for message in cargo_metadata::Message::parse_stream(output.stdout.as_slice()) { |
309 | if let Ok(message) = message { | 308 | if let Ok(message) = message { |
310 | match message { | 309 | match message { |
311 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { | 310 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { |
312 | res.out_dirs.insert(package_id.clone(), out_dir); | 311 | res.out_dirs.insert(package_id.clone(), out_dir); |
313 | res.cfgs.insert( | 312 | res.cfgs.insert(package_id, cfgs); |
314 | package_id, | ||
315 | // FIXME: Current `cargo_metadata` uses `PathBuf` instead of `String`, | ||
316 | // change when https://github.com/oli-obk/cargo_metadata/pulls/112 reaches crates.io | ||
317 | cfgs.iter().filter_map(|c| c.to_str().map(|s| s.to_owned())).collect(), | ||
318 | ); | ||
319 | } | 313 | } |
320 | |||
321 | Message::CompilerArtifact(message) => { | 314 | Message::CompilerArtifact(message) => { |
322 | if message.target.kind.contains(&"proc-macro".to_string()) { | 315 | if message.target.kind.contains(&"proc-macro".to_string()) { |
323 | let package_id = message.package_id; | 316 | let package_id = message.package_id; |
@@ -330,6 +323,8 @@ pub fn load_extern_resources( | |||
330 | } | 323 | } |
331 | Message::CompilerMessage(_) => (), | 324 | Message::CompilerMessage(_) => (), |
332 | Message::Unknown => (), | 325 | Message::Unknown => (), |
326 | Message::BuildFinished(_) => {} | ||
327 | Message::TextLine(_) => {} | ||
333 | } | 328 | } |
334 | } | 329 | } |
335 | } | 330 | } |