Skip to content

Commit 82c6787

Browse files
committed
spirv-builder: when no artifact is produced, error instead of panic
some cargo commands like clippy won't produce artifacts, so we want to ignore that error in cargo-gpu
1 parent 96fcc9d commit 82c6787

File tree

1 file changed

+5
-6
lines changed
  • crates/spirv-builder/src

1 file changed

+5
-6
lines changed

crates/spirv-builder/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ pub enum SpirvBuilderError {
129129
MetadataFileMissing(#[from] std::io::Error),
130130
#[error("unable to parse multi-module metadata file")]
131131
MetadataFileMalformed(#[from] serde_json::Error),
132+
#[error(
133+
"`{ARTIFACT_SUFFIX}` artifact not found in (supposedly successful) build output.\n--- build output ---\n{stdout}"
134+
)]
135+
NoArtifactProduced { stdout: String },
132136
#[error("cargo metadata error")]
133137
CargoMetadata(#[from] cargo_metadata::Error),
134138
#[cfg(feature = "watch")]
@@ -1096,12 +1100,7 @@ fn invoke_rustc(builder: &SpirvBuilder) -> Result<PathBuf, SpirvBuilderError> {
10961100
// that ended up on stdout instead of stderr.
10971101
let stdout = String::from_utf8(build.stdout).unwrap();
10981102
if build.status.success() {
1099-
get_sole_artifact(&stdout).ok_or_else(|| {
1100-
eprintln!("--- build output ---\n{stdout}");
1101-
panic!(
1102-
"`{ARTIFACT_SUFFIX}` artifact not found in (supposedly successful) build output (see above). Verify that `crate-type` is set correctly"
1103-
);
1104-
})
1103+
get_sole_artifact(&stdout).ok_or_else(|| SpirvBuilderError::NoArtifactProduced { stdout })
11051104
} else {
11061105
Err(SpirvBuilderError::BuildFailed)
11071106
}

0 commit comments

Comments
 (0)