(project_dir: &Path)
| 64 | } |
| 65 | |
| 66 | fn validate_project(project_dir: &Path) -> Result<ValidationReport, String> { |
| 67 | if !project_dir.join("project.toml").exists() { |
| 68 | return Err(format!( |
| 69 | "invalid project path `{}`. Expected project.toml.", |
| 70 | project_dir.display() |
| 71 | )); |
| 72 | } |
| 73 | |
| 74 | let mut report = ValidationReport::default(); |
| 75 | let config = match load_project_toml(project_dir) { |
| 76 | Ok(config) => config, |
| 77 | Err(err) => { |
| 78 | report.error(format!("project.toml parse failed: {err}")); |
| 79 | return Ok(report); |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | validate_project_config_refs(project_dir, &config, &mut report); |
| 84 | |
| 85 | let mut files = Vec::new(); |
| 86 | collect_reference_text_files(project_dir, &mut files)?; |
| 87 | for file in files { |
| 88 | report.checked_files += 1; |
| 89 | let text = fs::read_to_string(&file) |
| 90 | .map_err(|err| format!("failed to read {}: {err}", file.display()))?; |
| 91 | for text_ref in extract_virtual_refs(&text) { |
| 92 | report.checked_refs += 1; |
| 93 | validate_virtual_ref( |
| 94 | project_dir, |
| 95 | Some(&file), |
| 96 | Some(text_ref.line), |
| 97 | &text_ref.raw, |
| 98 | &mut report, |
| 99 | ); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | validate_script_warnings(project_dir, &mut report)?; |
| 104 | validate_shaders(project_dir, &mut report)?; |
| 105 | |
| 106 | Ok(report) |
| 107 | } |
| 108 | |
| 109 | // Game `.wgsl` files only become full modules once the engine wraps a prelude |
no test coverage detected