BlueGit

ict rusty-teams

Files

rusty-teams / crates / calling / build.rs

build.rs

build.rs 943 B Download Raw
1use std::io::Write as _;
2
3fn main() {
4 println!("cargo::rustc-check-cfg=cfg(embedded_onnxruntime)");
5 println!("cargo::rerun-if-env-changed=CALLING_ONNXRUNTIME_DLL");
6 let windows = std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows");
7 let Some(library) = std::env::var_os("CALLING_ONNXRUNTIME_DLL").filter(|_| windows) else { return };
8 println!("cargo::rerun-if-changed={}", library.to_string_lossy());
9 let bytes = std::fs::read(&library).expect("CALLING_ONNXRUNTIME_DLL is readable");
10 let output = std::path::Path::new(&std::env::var("OUT_DIR").expect("out dir")).join("onnxruntime.dll.deflate");
11 let mut encoder = flate2::write::DeflateEncoder::new(std::fs::File::create(&output).expect("deflate output"), flate2::Compression::best());
12 encoder.write_all(&bytes).expect("deflate written");
13 encoder.finish().expect("deflate finished");
14 println!("cargo::rustc-cfg=embedded_onnxruntime");
15}