build.rs 597 B

123456789101112131415161718192021
  1. use std::env;
  2. fn main() {
  3. check_rust_version();
  4. println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH");
  5. if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") {
  6. println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
  7. } else {
  8. let arch = env::var("HOST").unwrap();
  9. let arch = arch.split_once('-').map_or(&*arch, |x| x.0);
  10. println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
  11. }
  12. }
  13. #[rustversion::nightly]
  14. fn check_rust_version() {
  15. println!("cargo:rustc-cfg=unstable");
  16. }
  17. #[rustversion::not(nightly)]
  18. fn check_rust_version() {}