Skip to content

Commit

Permalink
back to xz2 (better build system)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Dec 30, 2023
1 parent cc089c9 commit 10552ce
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 45 deletions.
50 changes: 16 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ webpki-roots = "0.25"
thousands = "0.2"
tar = { version = "0.4", default-features = false }
ruzstd = "0.5"
xz2 = { version = "0.1", features = ["static"] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
raw-cpuid = "11"

[build-dependencies]
glob = "0.3"
tar = { version = "0.4", default-features = false }
zstd = { version = "0.13", default-features = false }
xz2 = "0.1"

[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
12 changes: 5 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@
use std::{env, fs, fs::File, io::Write, path::Path, process::Command};

use glob::glob;
use xz2::write::XzEncoder;

const EVAL_FILE: &str = "nn-5af11540bbfe.nnue";

fn main() {
hooks();

let mut archive = tar::Builder::new(
zstd::Encoder::new(
File::create(Path::new(&env::var("OUT_DIR").unwrap()).join("assets.tar.zst")).unwrap(),
19,
)
.unwrap(),
);
let mut archive = tar::Builder::new(XzEncoder::new(
File::create(Path::new(&env::var("OUT_DIR").unwrap()).join("assets.tar.xz")).unwrap(),
6,
));
archive.mode(tar::HeaderMode::Deterministic);
stockfish_build(&mut archive);
stockfish_eval_file(EVAL_FILE, &mut archive);
Expand Down
6 changes: 3 additions & 3 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ use std::{fmt, io, path::PathBuf};
use bitflags::bitflags;
use serde::Serialize;
use tempfile::TempDir;
use xz2::read::XzDecoder;

static ASSETS_TAR_ZST: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/assets.tar.zst"));
static ASSETS_TAR_XZ: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/assets.tar.xz"));

bitflags! {
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -181,8 +182,7 @@ impl Assets {
let mut stockfish = ByEngineFlavor::<Option<PathBuf>>::default();
let dir = tempfile::Builder::new().prefix("fishnet-").tempdir()?;

let mut archive =
tar::Archive::new(ruzstd::StreamingDecoder::new(ASSETS_TAR_ZST).expect("zst"));
let mut archive = tar::Archive::new(XzDecoder::new(ASSETS_TAR_XZ));
for entry in archive.entries()? {
let mut entry = entry?;
let path = entry.path()?;
Expand Down

0 comments on commit 10552ce

Please sign in to comment.