-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
28 lines (25 loc) · 777 Bytes
/
Copy pathbuild.rs
File metadata and controls
28 lines (25 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::{fs, path::Path};
use walkdir::WalkDir;
fn main() {
for entry in WalkDir::new("src")
.into_iter()
.filter_map(Result::ok)
.filter(|e| e.path().extension().is_some_and(|ext| ext == "wgsl"))
{
let path = entry.path();
validate_shader(path);
println!("cargo:rerun-if-changed={}", path.display());
}
}
fn validate_shader(path: &Path) {
let source =
fs::read_to_string(path).unwrap_or_else(|_| panic!("Failed to read shader at {path:?}"));
if let Err(err) = naga::front::wgsl::parse_str(&source) {
eprintln!(
"WGSL shader compile error in {:?}:\n{}",
path,
err.emit_to_string(&source)
);
panic!("Shader compilation failed.");
}
}