build.rs 788 B

1234567891011121314151617181920212223
  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. println!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\"))");
  13. println!("cargo::rustc-check-cfg=cfg(unstable)");
  14. }
  15. #[rustversion::nightly]
  16. fn check_rust_version() {
  17. println!("cargo:rustc-cfg=unstable");
  18. }
  19. #[rustversion::not(nightly)]
  20. fn check_rust_version() {}