Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
symcheck: Improve diagnostics from spawned Cargo
Rather than printing the entire JSON dump, use the rendered version.
  • Loading branch information
tgross35 committed Jul 4, 2025
commit 84060f608b375d77bed9845709d57441393ceed6
29 changes: 22 additions & 7 deletions library/compiler-builtins/crates/symbol-check/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
}

Expand Down