Files
sbv2-api/crates/sbv2_core/build.rs
Googlefan 932af5cbfb fix
2025-02-22 09:23:08 +00:00

21 lines
682 B
Rust

use std::env;
use std::fs;
use std::io::copy;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let out_dir = env::var("OUT_DIR")?;
let out_path = Path::new(&out_dir).join("all.bin");
if !out_path.exists() {
println!("cargo:warning=Downloading dictionary file...");
let mut response =
ureq::get("https://huggingface.co/neody/sbv2-api-assets/resolve/main/dic/all.bin")
.call()?;
let mut response = response.body_mut().as_reader();
let mut file = fs::File::create(&out_path)?;
copy(&mut response, &mut file)?;
}
println!("cargo:rerun-if-changed=build.rs");
Ok(())
}