-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
33 lines (26 loc) · 939 Bytes
/
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
use fs_extra::dir::copy;
use fs_extra::dir::CopyOptions;
use std::env;
use std::path::PathBuf;
fn main() {
let profile = env::var("PROFILE").unwrap(); // "release" for release builds, "debug" for other builds
if profile == "release" {
copy_resources();
}
}
fn copy_resources() {
let dest = env::var("CARGO_MANIFEST_DIR").unwrap();
let from = env::var("CARGO_MANIFEST_DIR").unwrap();
let profile = env::var("PROFILE").unwrap();
//Initialize default values for CopyOptions
let mut options = CopyOptions::new();
options.overwrite = true;
// options.mirror_copy = true; // To mirror copy the whole structure of the source directory
let mut dest_path = PathBuf::from(dest);
dest_path.push("target");
dest_path.push(profile);
let mut from_path = PathBuf::from(from);
from_path.push("resources");
// copy source/dir1 to target/dir1
copy(from_path.as_path(), dest_path.as_path(), &options).unwrap();
}