build.rs 653 B

1234567891011121314
  1. use std::env;
  2. fn main() {
  3. println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH");
  4. if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") {
  5. println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
  6. } else {
  7. let arch = env::var("HOST").unwrap();
  8. let arch = arch.split_once('-').map_or(&*arch, |x| x.0);
  9. println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
  10. }
  11. println!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\"))");
  12. println!("cargo::rustc-check-cfg=cfg(target_arch, values(\"asmjs\",\"nvptx\",\"xtensa\"))");
  13. }