-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile.toml
64 lines (55 loc) · 2 KB
/
Makefile.toml
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
[env]
VCPKGRS_DYNAMIC = "1"
VCPKG_PATH = "${VCPKG_PATH}"
PKG_CONFIG_ALLOW_CROSS = "1"
[tasks.build-win-cargo-debug]
condition = {env_not_set = ["RELEASE"]}
command = "cargo"
args = ["build", "--target=${TARGET}"]
[tasks.build-win-cargo-release]
condition = {env_set = ["RELEASE"]}
command = "cargo"
args = ["build", "--release", "--target=${TARGET}"]
[tasks.build-win-cargo]
dependencies = ["build-win-cargo-release", "build-win-cargo-debug"]
[tasks.build-win]
script_runner = "@rust"
script = [
'''
//! ```cargo
//! [dependencies]
//! walkdir = "2"
//! glob = "0.2.11"
//! fs_extra = "1.1"
//! ```
extern crate walkdir;
extern crate glob;
extern crate fs_extra;
use walkdir::WalkDir;
use glob::glob;
fn main() {
for entry in WalkDir::new(std::path::Path::new(&std::env::current_dir().unwrap()).join("target")).into_iter().filter_map(|e| e.ok()) {
let path = entry.path();
let share_src = std::path::Path::new(&std::env::current_dir().unwrap()).join("assets").join("share");
if path.is_dir() && (path.file_name().unwrap() == "debug" || path.file_name().unwrap() == "release") {
let mut copy_opts = fs_extra::dir::CopyOptions::new();
copy_opts.overwrite = true;
fs_extra::dir::copy(share_src, path, ©_opts).expect("unable to copy assets");
for entry in glob(&(String::from(path.to_str().expect("cannot convert path to str")) + "\\**\\*.dll")).expect("Failed to read glob pattern") {
match entry {
Ok(dll_path) => {
let target = path.join(dll_path.file_name().expect("cannot get dll name"));
if dll_path != target {
std::fs::copy(dll_path.clone(), target).expect("cannot copy file");
}
},
Err(_) => panic!(),
}
}
}
}
}
'''
]
dependencies = ["build-win-cargo"]
[tasks.package-win]