Files
iAs/ias-service/build.rs
T
wunianxiao 640ba9e7d2 feat: add React UI and AI page sharing tools
Move HTTP page rendering to the React app, fix multi-tool-call message handling, add API docs lookup, web page lookup, and Markdown preview page sharing.
2026-07-07 22:27:14 +08:00

30 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
use std::fs;
use std::path::Path;
fn main() {
let migrations = Path::new("migrations");
println!("cargo:rerun-if-changed={}", migrations.display());
let mut count = 0u64;
if let Ok(entries) = fs::read_dir(migrations) {
for entry in entries.flatten() {
let path = entry.path();
if path.extension().is_some_and(|extension| extension == "sql") {
println!("cargo:rerun-if-changed={}", path.display());
// 将文件大小加入计数,确保新增/删除/修改文件都改变输出
count = count.wrapping_add(fs::metadata(&path).map(|m| m.len()).unwrap_or(0));
}
}
}
// 将 migration 摘要写入 OUT_DIRlib.rs 通过 include! 引用。
// 这样 cargo 可以追踪 migration 变更 → lib.rs 重编译 → sqlx::migrate! 重新展开。
let out_dir = std::env::var("OUT_DIR").unwrap();
let dest = Path::new(&out_dir).join("migration_stamp.rs");
fs::write(
&dest,
format!("// generated by build.rs\npub const MIGRATION_STAMP: u64 = {count};\n"),
)
.unwrap();
}