-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
74 lines (68 loc) · 2.06 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
use std::env;
use winres::{VersionInfo, WindowsResource};
extern crate winres;
fn main() {
let mut res = WindowsResource::new();
if cfg!(unix) {
// from https://github.com/mxre/winres/blob/1807bec3552cd2f0d0544420584d6d78be5e3636/example/build.rs#L10
res.set_toolkit_path("/home/hagb/my_msvc/");
// ar tool for mingw in toolkit path
res.set_ar_path("/usr/i686-w64-mingw32/bin/ar");
// windres tool
res.set_windres_path("/usr/bin/i686-w64-mingw32-windres");
}
if let Some(version_pre) = env::var("CARGO_PKG_VERSION_PRE")
.unwrap()
.splitn(2, "-")
.next()
{
let mut version = 0_u64;
version |= env::var("CARGO_PKG_VERSION_MAJOR")
.unwrap()
.parse()
.unwrap_or(0)
<< 48;
version |= env::var("CARGO_PKG_VERSION_MINOR")
.unwrap()
.parse()
.unwrap_or(0)
<< 32;
version |= env::var("CARGO_PKG_VERSION_PATCH")
.unwrap()
.parse()
.unwrap_or(0)
<< 16;
version |= version_pre.parse().unwrap_or(0);
res.set_version_info(VersionInfo::FILEVERSION, version);
res.set_version_info(VersionInfo::PRODUCTVERSION, version);
} else {
panic!();
}
res.set(
"LegalCopyright",
format!(
"Copyright (c) {}",
env::var("CARGO_PKG_AUTHORS")
.unwrap()
.split(":")
.collect::<Vec<_>>()
.join(", ")
)
.as_str(),
);
res.set("ProductName", env::var("CARGO_PKG_NAME").unwrap().as_str());
res.set(
"FileDescription",
env::var("CARGO_PKG_DESCRIPTION").unwrap().as_str(),
);
if let Ok(repo) = env::var("SOURCE_URL") {
res.set(
"ProductVersion",
format!("{} ({})", env::var("CARGO_PKG_VERSION").unwrap(), repo).as_str(),
);
}
if let Err(e) = res.compile() {
eprintln!("{}", e);
std::process::exit(1);
}
}