spirv-builder: pass through non-JSON stdout lines even after an error. (#267)

This commit is contained in:
Eduard-Mihai Burtescu 2020-11-20 20:25:21 +02:00 committed by GitHub
parent 0581f8580e
commit 6e0e23c620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,9 +162,14 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
.env("RUSTFLAGS", rustflags) .env("RUSTFLAGS", rustflags)
.output() .output()
.expect("failed to execute cargo build"); .expect("failed to execute cargo build");
// `get_last_artifact` has the side-effect of printing invalid lines, so
// we do that even in case of an error, to let through any useful messages
// that ended up on stdout instead of stderr.
let stdout = String::from_utf8(build.stdout).unwrap();
let artifact = get_last_artifact(&stdout);
if build.status.success() { if build.status.success() {
let stdout = String::from_utf8(build.stdout).unwrap();
let artifact = get_last_artifact(&stdout);
if builder.print_metadata { if builder.print_metadata {
print_deps_of(&artifact); print_deps_of(&artifact);
} }