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