1 use std::path::PathBuf;
2
3 use cc::Build;
4
5 use crate::utils::cargo_handler::{CargoHandler, TargetArch};
6
7 pub mod riscv64;
8
9 pub(super) trait CFilesArch {
10 /// 设置架构相关的宏定义
setup_defines(&self, c: &mut Build)11 fn setup_defines(&self, c: &mut Build);
12 /// 设置架构相关的全局包含目录
setup_global_include_dir(&self, c: &mut Build)13 fn setup_global_include_dir(&self, c: &mut Build);
14 /// 设置需要编译的架构相关的文件
setup_files(&self, c: &mut Build, files: &mut Vec<PathBuf>)15 fn setup_files(&self, c: &mut Build, files: &mut Vec<PathBuf>);
16
17 /// 设置架构相关的全局编译标志
setup_global_flags(&self, c: &mut Build)18 fn setup_global_flags(&self, c: &mut Build);
19 }
20
21 /// 获取当前的架构;
current_cfiles_arch() -> &'static dyn CFilesArch22 pub(super) fn current_cfiles_arch() -> &'static dyn CFilesArch {
23 let arch = CargoHandler::target_arch();
24 match arch {
25 TargetArch::Riscv64 => &riscv64::RiscV64CFilesArch,
26 _ => panic!("Unsupported arch: {:?}", arch),
27 }
28 }
29