//! Check the model is a model and not an LFS pointer. //! //! `models/keypoints/*.onnx` is stored in Git LFS (see `.gitattributes`). A //! clone made without git-lfs, or with `GIT_LFS_SKIP_SMUDGE` set, leaves a //! ~130-byte text pointer at that path instead of the weights, and //! `include_bytes!` would embed it without complaint. Same guard as //! `dr-segment`'s, for the same failure. use std::path::Path; const MODEL: &str = "../../models/keypoints/xfeat-1024.onnx"; fn main() { println!("cargo:rerun-if-changed={MODEL}"); println!("cargo:rerun-if-changed=build.rs"); if std::env::var_os("CARGO_FEATURE_EMBEDDED_MODEL").is_none() { return; } let path = Path::new(MODEL); let Ok(bytes) = std::fs::read(path) else { panic!( "\n\n{MODEL} is missing.\n\ It ships in Git LFS. Run `git lfs install && git lfs pull`, or build \ with `--no-default-features` for a geometry-only build.\n" ); }; if bytes.starts_with(b"version https://git-lfs.github.com/spec/") { panic!( "\n\n{MODEL} is a Git LFS pointer, not the model.\n\ Run `git lfs install && git lfs pull`, or build with \ `--no-default-features` for a geometry-only build.\n" ); } }