-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (22 loc) · 729 Bytes
/
Copy pathbuild.rs
File metadata and controls
27 lines (22 loc) · 729 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
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=assets/*");
let src_dir = "assets";
let out_dir = std::path::Path::new(&std::env::var("OUT_DIR").unwrap()).join("assets");
copy_directory(src_dir, out_dir).unwrap();
}
fn copy_directory(
src: impl AsRef<Path>,
dst: impl AsRef<Path>,
) -> Result<(), Box<dyn std::error::Error>> {
std::fs::create_dir_all(&dst)?;
for entry in std::fs::read_dir(src)? {
let entry = entry?;
if entry.file_type()?.is_dir() {
copy_directory(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}