diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-02-04 00:27:16 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-02-04 00:27:16 +0800 |
| commit | d19e5d84ee21502fd3440511d4ffb1ee1f49d3b2 (patch) | |
| tree | fb8efef6f8e9a26c5b60d4ac220b11d6c6f0775e /gen/gen_compile_info.rs | |
| parent | 7ee0d3f20c875e7405bb8442c5eb0228d1599a03 (diff) | |
Refactor build system and implement complete renderer system
- Split monolithic build.rs into modular async generators
- Add renderer override system with type-safe dispatch
- Implement command template macro for consistent command definitions
- Add proc-macro crates for command and renderer systems
- Reorganize directory structure for better separation of concerns
- Update documentation to reflect new architecture
Diffstat (limited to 'gen/gen_compile_info.rs')
| -rw-r--r-- | gen/gen_compile_info.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gen/gen_compile_info.rs b/gen/gen_compile_info.rs new file mode 100644 index 0000000..5af030c --- /dev/null +++ b/gen/gen_compile_info.rs @@ -0,0 +1,37 @@ +use std::path::PathBuf; + +use crate::r#gen::{ + constants::{COMPILE_INFO_RS, COMPILE_INFO_RS_TEMPLATE}, + env::{get_git_branch, get_git_commit, get_platform, get_toolchain, get_version}, +}; + +/// Generate compile info +pub async fn generate_compile_info(repo_root: &PathBuf) { + // Read the template code + let template_code = tokio::fs::read_to_string(repo_root.join(COMPILE_INFO_RS_TEMPLATE)) + .await + .unwrap(); + + let date = chrono::Local::now().format("%Y-%m-%d %H:%M:%S").to_string(); + let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string()); + let platform = get_platform(&target); + let toolchain = get_toolchain(); + let version = get_version(); + let branch = get_git_branch().unwrap_or_else(|_| "unknown".to_string()); + let commit = get_git_commit().unwrap_or_else(|_| "unknown".to_string()); + + let generated_code = template_code + .replace("{date}", &date) + .replace("{target}", &target) + .replace("{platform}", &platform) + .replace("{toolchain}", &toolchain) + .replace("{version}", &version) + .replace("{branch}", &branch) + .replace("{commit}", &commit); + + // Write the generated code + let compile_info_path = repo_root.join(COMPILE_INFO_RS); + tokio::fs::write(compile_info_path, generated_code) + .await + .unwrap(); +} |
