MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / get_sole_artifact

Function get_sole_artifact

crates/spirv-builder/src/lib.rs:764–792  ·  view source on GitHub ↗
(out: &str)

Source from the content-addressed store, hash-verified

762const ARTIFACT_SUFFIX: &str = ".spv.json";
763
764fn get_sole_artifact(out: &str) -> Option<PathBuf> {
765 let last = out
766 .lines()
767 .filter_map(|line| {
768 if let Ok(line) = serde_json::from_str::<RustcOutput>(line) {
769 Some(line)
770 } else {
771 // Pass through invalid lines
772 println!("{line}");
773 None
774 }
775 })
776 .filter(|line| line.reason == "compiler-artifact")
777 .last()
778 .expect("Did not find output file in rustc output");
779
780 let mut filenames = last
781 .filenames
782 .unwrap()
783 .into_iter()
784 .filter(|v| v.ends_with(ARTIFACT_SUFFIX));
785 let filename = filenames.next()?;
786 assert_eq!(
787 filenames.next(),
788 None,
789 "build had multiple `{ARTIFACT_SUFFIX}` artifacts"
790 );
791 Some(filename.into())
792}
793
794/// Internally iterate through the leaf dependencies of the artifact at `artifact`
795fn leaf_deps(artifact: &Path, mut handle: impl FnMut(&RawStr)) -> std::io::Result<()> {

Callers 1

invoke_rustcFunction · 0.85

Calls 3

expectMethod · 0.80
into_iterMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected