diff options
| author | Trevor Gross <tmgross@umich.edu> | 2025-07-04 18:10:27 -0500 |
|---|---|---|
| committer | Trevor Gross <tmgross@umich.edu> | 2025-07-04 18:18:31 -0500 |
| commit | 84060f608b375d77bed9845709d57441393ceed6 (patch) | |
| tree | 0ee8447e15bf975e9f12a51467b6c5a617d3d785 /library/compiler-builtins/crates/symbol-check/src | |
| parent | e164811f5d69c00baf93694dfe203001b40ecdeb (diff) | |
| download | rust-84060f608b375d77bed9845709d57441393ceed6.tar.gz rust-84060f608b375d77bed9845709d57441393ceed6.zip | |
symcheck: Improve diagnostics from spawned Cargo
Rather than printing the entire JSON dump, use the rendered version.
Diffstat (limited to 'library/compiler-builtins/crates/symbol-check/src')
| -rw-r--r-- | library/compiler-builtins/crates/symbol-check/src/main.rs | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/library/compiler-builtins/crates/symbol-check/src/main.rs b/library/compiler-builtins/crates/symbol-check/src/main.rs index f60d4f0d36f..1312a717970 100644 --- a/library/compiler-builtins/crates/symbol-check/src/main.rs +++ b/library/compiler-builtins/crates/symbol-check/src/main.rs @@ -87,9 +87,14 @@ fn host_target() -> String { /// libraries. fn exec_cargo_with_args(target: &str, args: &[&str]) -> Vec<PathBuf> { let mut cmd = Command::new("cargo"); - cmd.args(["build", "--target", target, "--message-format=json"]) - .args(args) - .stdout(Stdio::piped()); + cmd.args([ + "build", + "--target", + target, + "--message-format=json-diagnostic-rendered-ansi", + ]) + .args(args) + .stdout(Stdio::piped()); println!("running: {cmd:?}"); let mut child = cmd.spawn().expect("failed to launch Cargo"); @@ -100,11 +105,21 @@ fn exec_cargo_with_args(target: &str, args: &[&str]) -> Vec<PathBuf> { for line in reader.lines() { let line = line.expect("failed to read line"); - println!("{line}"); // tee to stdout - - // Select only steps that create files let j: Value = serde_json::from_str(&line).expect("failed to deserialize"); - if j["reason"] != "compiler-artifact" { + let reason = &j["reason"]; + + // Forward output that is meant to be user-facing + if reason == "compiler-message" { + println!("{}", j["message"]["rendered"].as_str().unwrap()); + } else if reason == "build-finished" { + println!("build finshed. success: {}", j["success"]); + } else if reason == "build-script-executed" { + let pretty = serde_json::to_string_pretty(&j).unwrap(); + println!("build script output: {pretty}",); + } + + // Only interested in the artifact list now + if reason != "compiler-artifact" { continue; } |
