Files
Genarrative/apps/ai-game-creator-shell/src-tauri/build.rs
kdletters 578f8019fc
Project CI / Repository checks (push) Successful in 1m14s
Project CI / Frontend tests (push) Successful in 3m9s
Project CI / Backend tests (push) Successful in 3m58s
Project CI / Native shell tests (push) Successful in 14m6s
优化AGC项目入口并识别Godot工作区
项目页只保留打开项目和新建项目并统一原生目录选择
按根目录及一层子目录识别project.godot并记录相对Godot根
保持.agent位于用户选择的工作区根并补齐Windows构建门禁
补充响应式布局、测试、技术方案和共享项目记忆
2026-08-14 21:53:43 +08:00

80 lines
2.9 KiB
Rust

#[path = "build_support/frontend_dist_guard.rs"]
mod frontend_dist_guard;
#[path = "build_support/runtime_prompt_bundle.rs"]
mod runtime_prompt_bundle;
use std::collections::BTreeSet;
use std::env;
use std::fs;
use std::path::PathBuf;
fn seed_task_group_id(
group: &shared_contracts::game_creation_app::GameCreationAppAgentGroup,
) -> &'static str {
use shared_contracts::game_creation_app::GameCreationAppAgentGroup;
match group {
GameCreationAppAgentGroup::Design => "design",
GameCreationAppAgentGroup::Art => "art",
GameCreationAppAgentGroup::Code => "code",
GameCreationAppAgentGroup::Balance => "balance",
GameCreationAppAgentGroup::Audio => "audio",
GameCreationAppAgentGroup::Publishing => "publishing",
}
}
fn validate_seed_task_catalog(compiled: &runtime_prompt_bundle::CompiledPromptBundle) {
let actual = compiled
.specialist_nodes
.iter()
.map(|node| {
(
node.task_id.clone(),
node.group_id.clone(),
node.role.clone(),
)
})
.collect::<BTreeSet<_>>();
let expected = shared_contracts::game_creation_app::new_game_creation_app_seed_tasks()
.into_iter()
.map(|task| {
(
task.id,
seed_task_group_id(&task.group).to_string(),
task.role,
)
})
.collect::<BTreeSet<_>>();
if actual != expected {
panic!(
"Prompt Bundle agentCatalog 与正式 seed DAG 的 taskId/group/role 不一致\nactual={actual:#?}\nexpected={expected:#?}"
);
}
}
fn main() {
let manifest_dir = PathBuf::from(
env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR must be available"),
);
let manifest_path = manifest_dir.join("prompts/runtime/manifest.json");
let compiled = runtime_prompt_bundle::compile_manifest(&manifest_path)
.unwrap_or_else(|error| panic!("Prompt Bundle 编译失败:{error}"));
validate_seed_task_catalog(&compiled);
for dependency in &compiled.dependencies {
println!("cargo:rerun-if-changed={}", dependency.display());
}
let output_path = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR must be available"))
.join("agent_runtime_prompt_bundle.rs");
fs::write(&output_path, compiled.rust_source)
.unwrap_or_else(|error| panic!("写入 Prompt Bundle 生成代码失败:{error}"));
if !tauri_build::is_dev() {
let frontend_dist = manifest_dir
.parent()
.expect("AI 游戏创作 Tauri manifest 必须位于应用目录下")
.join("dist");
println!("cargo:rerun-if-changed={}", frontend_dist.display());
frontend_dist_guard::validate_frontend_dist(&frontend_dist)
.unwrap_or_else(|error| panic!("生产 frontendDist 检查失败:{error}"));
}
tauri_build::build()
}