Skip to content

Commit

Permalink
asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
pacak committed Mar 14, 2024
1 parent fcd5425 commit cf59751
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/rlib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::esafeprint;
use crate::esafeprintln;
use ar::Archive;
use cargo_metadata::Artifact;
use std::{
Expand Down Expand Up @@ -36,6 +36,7 @@ pub fn locate_byproducts(rlib: impl AsRef<Path>, ext: &str) -> anyhow::Result<Ve
let basedir = rlib
.parent()
.ok_or_else(|| anyhow::anyhow!("Can't get a folder of {rlib:?}"))?;
let mut missing = Vec::new();
while let Some(entry) = archive.next_entry() {
let entry = entry?;
let name = std::str::from_utf8(entry.header().identifier())?;
Expand All @@ -48,9 +49,24 @@ pub fn locate_byproducts(rlib: impl AsRef<Path>, ext: &str) -> anyhow::Result<Ve
if x.exists() {
res.push(x)
} else {
esafeprint!("A byproduct is supposed to be located at {x:?}, but it's missing");
missing.push(x);
}
}
if !res.is_empty() && missing.is_empty() {
for file in &missing {
esafeprintln!("A byproduct is supposed to be located at {file:?}, but it's missing");
}
}

if missing.len() == 1 && res.is_empty() {
assert_eq!(missing[0].extension().unwrap(), ext);
let f = missing[0]
.with_extension("")
.with_extension("")
.with_extension("")
.with_extension(ext);
return Ok(vec![f]);
}

Ok(res)
}
Expand Down

0 comments on commit cf59751

Please sign in to comment.