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/cargo_workspace.rs7
-rw-r--r--crates/ra_project_model/src/lib.rs12
2 files changed, 14 insertions, 5 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index bf83adc42..16fff9f1c 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -56,6 +56,9 @@ pub struct CargoConfig {
56 56
57 /// Runs cargo check on launch to figure out the correct values of OUT_DIR 57 /// Runs cargo check on launch to figure out the correct values of OUT_DIR
58 pub load_out_dirs_from_check: bool, 58 pub load_out_dirs_from_check: bool,
59
60 /// rustc target
61 pub target: Option<String>,
59} 62}
60 63
61impl Default for CargoConfig { 64impl Default for CargoConfig {
@@ -65,6 +68,7 @@ impl Default for CargoConfig {
65 all_features: true, 68 all_features: true,
66 features: Vec::new(), 69 features: Vec::new(),
67 load_out_dirs_from_check: false, 70 load_out_dirs_from_check: false,
71 target: None,
68 } 72 }
69 } 73 }
70} 74}
@@ -161,6 +165,9 @@ impl CargoWorkspace {
161 if let Some(parent) = cargo_toml.parent() { 165 if let Some(parent) = cargo_toml.parent() {
162 meta.current_dir(parent); 166 meta.current_dir(parent);
163 } 167 }
168 if let Some(target) = cargo_features.target.as_ref() {
169 meta.other_options(&[String::from("--filter-platform"), target.clone()]);
170 }
164 let meta = meta.exec().with_context(|| { 171 let meta = meta.exec().with_context(|| {
165 format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) 172 format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display())
166 })?; 173 })?;
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 7231da221..8703429d4 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -544,7 +544,7 @@ impl ProjectWorkspace {
544 } 544 }
545} 545}
546 546
547pub fn get_rustc_cfg_options() -> CfgOptions { 547pub fn get_rustc_cfg_options(target: Option<&String>) -> CfgOptions {
548 let mut cfg_options = CfgOptions::default(); 548 let mut cfg_options = CfgOptions::default();
549 549
550 // Some nightly-only cfgs, which are required for stdlib 550 // Some nightly-only cfgs, which are required for stdlib
@@ -559,10 +559,12 @@ pub fn get_rustc_cfg_options() -> CfgOptions {
559 559
560 match (|| -> Result<String> { 560 match (|| -> Result<String> {
561 // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here. 561 // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here.
562 let output = Command::new("rustc") 562 let mut cmd = Command::new("rustc");
563 .args(&["--print", "cfg", "-O"]) 563 cmd.args(&["--print", "cfg", "-O"]);
564 .output() 564 if let Some(target) = target {
565 .context("Failed to get output from rustc --print cfg -O")?; 565 cmd.args(&["--target", target.as_str()]);
566 }
567 let output = cmd.output().context("Failed to get output from rustc --print cfg -O")?;
566 if !output.status.success() { 568 if !output.status.success() {
567 bail!( 569 bail!(
568 "rustc --print cfg -O exited with exit code ({})", 570 "rustc --print cfg -O exited with exit code ({})",