Copies a `.glsl` or `.frag` file to the output directory, adding the generated header.
(source: &Path, rel_path: &Path, output_dir: &Path)
| 671 | |
| 672 | /// Copies a `.glsl` or `.frag` file to the output directory, adding the generated header. |
| 673 | fn copy_glsl(source: &Path, rel_path: &Path, output_dir: &Path) { |
| 674 | let stem = rel_path.file_stem().unwrap().to_string_lossy(); |
| 675 | let output_path = output_dir.join(format!("{}.frag.glsl", stem)); |
| 676 | |
| 677 | let content = std::fs::read_to_string(source) |
| 678 | .unwrap_or_else(|e| panic!("Failed to read '{}': {}", source.display(), e)); |
| 679 | |
| 680 | let header = format!( |
| 681 | "{}\n//! Source: {}\n", |
| 682 | GENERATED_HEADER_PREFIX, |
| 683 | rel_path.display() |
| 684 | ); |
| 685 | |
| 686 | std::fs::write(&output_path, format!("{}{}", header, content)) |
| 687 | .unwrap_or_else(|e| panic!("Failed to write '{}': {}", output_path.display(), e)); |
| 688 | } |
| 689 | |
| 690 | /// Prepends the generated file header to an existing compiled shader. |
| 691 | #[cfg(feature = "shader-build")] |