build.rs 1003 B

1234567891011121314151617
  1. use which::which;
  2. /// Building this crate has an undeclared dependency on the `bpf-linker` binary. This would be
  3. /// better expressed by [artifact-dependencies][bindeps] but issues such as
  4. /// https://github.com/rust-lang/cargo/issues/12385 make their use impractical for the time being.
  5. ///
  6. /// This file implements an imperfect solution: it causes cargo to rebuild the crate whenever the
  7. /// mtime of `which bpf-linker` changes. Note that possibility that a new bpf-linker is added to
  8. /// $PATH ahead of the one used as the cache key still exists. Solving this in the general case
  9. /// would require rebuild-if-changed-env=PATH *and* rebuild-if-changed={every-directory-in-PATH}
  10. /// which would likely mean far too much cache invalidation.
  11. ///
  12. /// [bindeps]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html?highlight=feature#artifact-dependencies
  13. fn main() {
  14. let bpf_linker = which("bpf-linker").unwrap();
  15. println!("cargo:rerun-if-changed={}", bpf_linker.to_str().unwrap());
  16. }