-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
92 lines (58 loc) · 2.4 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use std::env;
use std::fs;
use std::path::Path;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let resources_path = env::var("CARGO_MANIFEST_DIR").unwrap() +"/resources";
let settings_path = env::var("CARGO_MANIFEST_DIR").unwrap() +"/settings";
let devices_path = env::var("CARGO_MANIFEST_DIR").unwrap() +"/devices";
let dest_path_base = Path::new(&out_dir).parent().unwrap().parent().unwrap().parent().unwrap().to_str().unwrap();
let dest_resources_path = format!("{}/{}",dest_path_base, "resources");
fs::create_dir_all(&dest_resources_path).unwrap();
let dest_settings_path = format!("{}/{}",dest_path_base, "settings");
fs::create_dir_all(&dest_settings_path).unwrap();
let dest_devices_path = format!("{}/{}",dest_path_base, "devices");
fs::create_dir_all(&dest_devices_path).unwrap();
let files = fs::read_dir(&resources_path).unwrap();
for f in files {
println!("found file");
let p = f.unwrap().path();
let file = Path::new(&p);
if file.is_file() {
let name = file.file_name().unwrap().to_str().unwrap();
let source_path = format!("{}/{}", resources_path, name);
let dest_path = format!("{}/{}",dest_resources_path, name);
println!("source: {}",source_path);
println!("desc: {}",dest_path);
fs::copy(source_path, dest_path).unwrap();
}
}
let files = fs::read_dir(&settings_path).unwrap();
for f in files {
println!("found file");
let p = f.unwrap().path();
let file = Path::new(&p);
if file.is_file() {
let name = file.file_name().unwrap().to_str().unwrap();
let source_path = format!("{}/{}", settings_path, name);
let dest_path = format!("{}/{}",dest_settings_path, name);
println!("source: {}",source_path);
println!("desc: {}",dest_path);
fs::copy(source_path, dest_path).unwrap();
}
}
let files = fs::read_dir(&devices_path).unwrap();
for f in files {
println!("found file");
let p = f.unwrap().path();
let file = Path::new(&p);
if file.is_file() {
let name = file.file_name().unwrap().to_str().unwrap();
let source_path = format!("{}/{}", devices_path, name);
let dest_path = format!("{}/{}",dest_devices_path, name);
println!("source: {}",source_path);
println!("desc: {}",dest_path);
fs::copy(source_path, dest_path).unwrap();
}
}
}