build.rs 641 B

12345678910111213141516
  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 mut arch = arch.split_once('-').map_or(&*arch, |x| x.0);
  9. if arch.starts_with("riscv64") {
  10. arch = "riscv64";
  11. }
  12. println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
  13. }
  14. println!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\"))");
  15. }