-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (24 loc) · 691 Bytes
/
Copy pathbuild.rs
File metadata and controls
27 lines (24 loc) · 691 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::{
collections::HashMap,
path::{Path, PathBuf},
};
fn main() {
println!("cargo:rerun-if-changed=resource");
let files: HashMap<PathBuf, String> = walkdir::WalkDir::new("resource")
.into_iter()
.filter_map(Result::ok)
.map(|d| d.into_path())
.filter(|p| p.is_file())
.map(|p| {
(
p.strip_prefix("resource").unwrap().to_owned(),
hex::encode(std::fs::read(p).unwrap()),
)
})
.collect();
std::fs::write(
Path::new(&std::env::var("OUT_DIR").unwrap()).join("resource.json"),
serde_json::to_string(&files).unwrap(),
)
.unwrap();
}