forked from alphastrata/shadplay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
32 lines (28 loc) · 1.09 KB
/
build.rs
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
29
30
31
32
use std::fs;
use std::path::PathBuf;
use std::process::exit;
fn main() {
// Clone the Bevy repository
if !PathBuf::from("bevy").exists()
&& !std::process::Command::new("git")
.args(["clone", "https://github.com/bevyengine/bevy"])
.status()
.expect("Failed to execute git clone command")
.success()
{
eprintln!("Failed to clone Bevy repository");
exit(1);
}
// Collect paths of all .wgsl files using `glob` crate
let wgsl_files = glob::glob("bevy/**/*.wgsl")
.expect("Failed to read .wgsl files")
.filter_map(Result::ok);
// Create the 'bevy_shaders' directory
fs::create_dir_all("bevy_shaders").expect("Failed to create 'bevy_shaders' directory");
// Move the .wgsl files to the 'bevy_shaders' directory
wgsl_files.into_iter().for_each(|path| {
let filename = path.file_name().expect("Failed to get filename");
let destination = format!("bevy_shaders/{}", filename.to_string_lossy());
fs::rename(path, destination).expect("Failed to move file");
});
}