-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.rs
More file actions
44 lines (37 loc) · 1.39 KB
/
build.rs
File metadata and controls
44 lines (37 loc) · 1.39 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
use std::path::{Path, PathBuf};
use walkdir::WalkDir;
fn main() {
let assets_path = Path::new("assets");
if assets_path.exists() {
println!("cargo:rerun-if-changed=assets");
for entry in WalkDir::new("assets") {
if let Ok(entry) = entry {
if entry.file_type().is_file() {
println!("cargo:rerun-if-changed={}", entry.path().display());
}
}
}
}
for file in &["config.toml", "bench.toml"] {
let source = Path::new(file);
if !source.exists() {
continue;
}
println!("cargo:rerun-if-changed={}", file);
}
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").expect("failed to get manifest dir");
let profile = std::env::var("PROFILE").expect("failed to get profile");
let target_dir = PathBuf::from(&manifest_dir).join("target").join(profile);
if !target_dir.exists() {
std::fs::create_dir_all(&target_dir).expect("failed to get dirs");
}
let options = fs_extra::dir::CopyOptions::new()
.overwrite(true)
.copy_inside(true);
fs_extra::dir::copy(assets_path, &target_dir, &options).expect("failed to copy");
for file in &["config.toml", "bench.toml"] {
let source = Path::new(file);
let dest = target_dir.join(file);
std::fs::copy(source, dest).expect("failed to build");
}
}