aboutsummaryrefslogtreecommitdiff
path: root/crates/project_model/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/project_model/src')
-rw-r--r--crates/project_model/src/build_data.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/crates/project_model/src/build_data.rs b/crates/project_model/src/build_data.rs
index fdf4b2d55..0d4d39fef 100644
--- a/crates/project_model/src/build_data.rs
+++ b/crates/project_model/src/build_data.rs
@@ -13,7 +13,7 @@ use cargo_metadata::{BuildScript, Message};
13use itertools::Itertools; 13use itertools::Itertools;
14use paths::{AbsPath, AbsPathBuf}; 14use paths::{AbsPath, AbsPathBuf};
15use rustc_hash::FxHashMap; 15use rustc_hash::FxHashMap;
16use stdx::JodChild; 16use stdx::{format_to, JodChild};
17 17
18use crate::{cfg_flag::CfgFlag, CargoConfig}; 18use crate::{cfg_flag::CfgFlag, CargoConfig};
19 19
@@ -35,6 +35,7 @@ pub(crate) struct PackageBuildData {
35#[derive(Debug, Default, PartialEq, Eq, Clone)] 35#[derive(Debug, Default, PartialEq, Eq, Clone)]
36pub(crate) struct WorkspaceBuildData { 36pub(crate) struct WorkspaceBuildData {
37 per_package: FxHashMap<String, PackageBuildData>, 37 per_package: FxHashMap<String, PackageBuildData>,
38 error: Option<String>,
38} 39}
39 40
40#[derive(Debug, Default, PartialEq, Eq, Clone)] 41#[derive(Debug, Default, PartialEq, Eq, Clone)]
@@ -94,6 +95,19 @@ impl BuildDataResult {
94 pub(crate) fn get(&self, workspace_root: &AbsPath) -> Option<&WorkspaceBuildData> { 95 pub(crate) fn get(&self, workspace_root: &AbsPath) -> Option<&WorkspaceBuildData> {
95 self.per_workspace.get(workspace_root) 96 self.per_workspace.get(workspace_root)
96 } 97 }
98 pub fn error(&self) -> Option<String> {
99 let mut buf = String::new();
100 for (_workspace_root, build_data) in &self.per_workspace {
101 if let Some(err) = &build_data.error {
102 format_to!(buf, "cargo check failed:\n{}", err);
103 }
104 }
105 if buf.is_empty() {
106 return None;
107 }
108
109 Some(buf)
110 }
97} 111}
98 112
99impl BuildDataConfig { 113impl BuildDataConfig {
@@ -139,7 +153,7 @@ fn collect_from_workspace(
139 } 153 }
140 } 154 }
141 155
142 cmd.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()); 156 cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).stdin(Stdio::null());
143 157
144 let mut child = cmd.spawn().map(JodChild)?; 158 let mut child = cmd.spawn().map(JodChild)?;
145 let child_stdout = child.stdout.take().unwrap(); 159 let child_stdout = child.stdout.take().unwrap();
@@ -209,6 +223,15 @@ fn collect_from_workspace(
209 } 223 }
210 } 224 }
211 225
226 let output = child.into_inner().wait_with_output()?;
227 if !output.status.success() {
228 let mut stderr = String::from_utf8(output.stderr).unwrap_or_default();
229 if stderr.is_empty() {
230 stderr = "cargo check failed".to_string();
231 }
232 res.error = Some(stderr)
233 }
234
212 Ok(res) 235 Ok(res)
213} 236}
214 237