refactor: 迁移 winapi 到 windows-sys,修复配置解析漏洞

- 依赖替换为 windows-sys 0.61,main.rs 全面适配新 API
  - 配置解析错误显式传播:env/args 类型错误、数组空洞、非法键不再静默
  吞错
  - 修正空环境变量与空参数语义,补充 UTF-8 与路径拼接校验
  - require 容错移至 Rust 侧,模块加载失败记录日志并跳过
  - 新增配置解析与运行时单元测试(19 个)
This commit is contained in:
2026-08-14 20:09:34 +08:00
parent ed5439eaa1
commit 5e69a6a980
13 changed files with 691 additions and 278 deletions

View File

@@ -18,18 +18,17 @@ fn main() {
// 在 target/debug/ 或 target/release/ 下创建 bin2 目录
let output_dir = target_dir.join(&profile).join("bin2");
// cargo:rerun-if-changed -> 当指定文件变化时,重新运行 xxx
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=shims.lua");
println!("cargo:rustc-env=OUTPUT_DIR={}", output_dir.display());
// 创建目录
let dirs = ["bin", "tools"];
for dir in &dirs {
let path = output_dir.join(dir);
let subdirs = ["bin", "tools"];
for subdir in &subdirs {
let path = output_dir.join(subdir);
if !path.exists() {
fs::create_dir_all(&path).expect(&format!("Failed to create {} directory", dir));
fs::create_dir_all(&path).expect(&format!("Failed to create {} directory", subdir));
println!("Created: {:?}", path);
}
}