1 use crate::utils::cargo_handler::{CargoHandler, TargetArch}; 2 3 use self::x86_64::X86_64BindgenArch; 4 5 pub mod riscv64; 6 pub mod x86_64; 7 8 pub(super) trait BindgenArch { generate_bindings(&self, builder: bindgen::Builder) -> bindgen::Builder9 fn generate_bindings(&self, builder: bindgen::Builder) -> bindgen::Builder; 10 } 11 12 /// 获取当前的bindgen架构; current_bindgenarch() -> &'static dyn BindgenArch13pub(super) fn current_bindgenarch() -> &'static dyn BindgenArch { 14 let arch = CargoHandler::target_arch(); 15 match arch { 16 TargetArch::X86_64 => &X86_64BindgenArch, 17 TargetArch::Riscv64 => &riscv64::RiscV64BindgenArch, 18 _ => panic!("Unsupported arch: {:?}", arch), 19 } 20 } 21