4
0

build.rs 873 B

1234567891011121314151617181920212223242526
  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 mut arch = arch.split_once('-').map_or(&*arch, |x| x.0);
  10. if arch.starts_with("riscv64") {
  11. arch = "riscv64";
  12. }
  13. println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
  14. }
  15. println!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\"))");
  16. println!("cargo::rustc-check-cfg=cfg(unstable)");
  17. }
  18. #[rustversion::nightly]
  19. fn check_rust_version() {
  20. println!("cargo:rustc-cfg=unstable");
  21. }
  22. #[rustversion::not(nightly)]
  23. fn check_rust_version() {}