Skip to content

Commit

Permalink
hardcode asset mode
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Mar 24, 2024
1 parent 1189125 commit fbc86ea
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 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);
append_file(archive, &exe_path);
append_file(archive, &exe_path, 0o755);
fs::remove_file(&exe_path).unwrap();
}

Expand All @@ -393,13 +393,12 @@ impl Target {
}

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

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

let mut header = ar::Header::new(
path.as_ref()
.file_name()
Expand All @@ -410,12 +409,6 @@ fn append_file<W: Write, P: AsRef<Path>>(archive: &mut ar::Builder<W>, path: P)
.to_vec(),
metadata.len(),
);

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

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

0 comments on commit fbc86ea

Please sign in to comment.