xref: /DragonOS/build-scripts/kernel_build/src/bindgen/arch/mod.rs (revision a8753f8fffb992e4d3bbd21eda431081b395af6b)
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