xref: /DragonOS/build-scripts/kernel_build/src/bindgen/arch/mod.rs (revision da152319797436368304cbc3f85a3b9ec049134b)
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 {
9     fn generate_bindings(&self, builder: bindgen::Builder) -> bindgen::Builder;
10 }
11 
12 /// 获取当前的bindgen架构;
13 pub(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