Skip to content

Commit

Permalink
do not include asset meta data other than name/size/mode
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Mar 24, 2024
1 parent 20c84d9 commit 1189125
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ impl Target {
);

let exe_path = Path::new(src_dir).join(exe);
archive.append_path(&exe_path).unwrap();
append_file(archive, &exe_path);
fs::remove_file(&exe_path).unwrap();
}

Expand All @@ -393,7 +393,29 @@ impl Target {
}

fn stockfish_eval_file<W: Write>(name: &str, archive: &mut ar::Builder<W>) {
archive
.append_path(Path::new("Stockfish").join("src").join(name))
.unwrap();
append_file(archive, Path::new("Stockfish").join("src").join(name));
}

fn append_file<W: Write, P: AsRef<Path>>(archive: &mut ar::Builder<W>, path: P) {
let file = File::open(&path).unwrap();
let metadata = file.metadata().unwrap();

let mut header = ar::Header::new(
path.as_ref()
.file_name()
.unwrap()
.to_str()
.unwrap()
.as_bytes()
.to_vec(),
metadata.len(),
);

#[cfg(unix)]
{
use std::os::unix::fs::MetadataExt;
header.set_mode(metadata.mode());
}

archive.append(&header, file).unwrap();
}

0 comments on commit 1189125

Please sign in to comment.