-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.rs
executable file
·51 lines (43 loc) · 1.47 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
#[cfg(windows)]
extern crate windres;
fn main() {
#[cfg(windows)]
windows::compile_resources_file();
}
#[cfg(windows)]
mod windows {
use std::env;
use std::fs;
use std::path::Path;
use windres::Build;
pub fn compile_resources_file() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let resource_header = Path::new(&out_dir).join("versions.h");
// Write include file for resource parameters based on cargo settings
let major = env!("CARGO_PKG_VERSION_MAJOR");
let minor = env!("CARGO_PKG_VERSION_MINOR");
let patch = env!("CARGO_PKG_VERSION_PATCH");
let full = env!("CARGO_PKG_VERSION");
let description = env!("CARGO_PKG_DESCRIPTION");
let auhtor = env!("CARGO_PKG_AUTHORS");
let name = env!("CARGO_PKG_NAME");
fs::write(
resource_header,
format!(
"
#define VERSION_MAJOR {major}
#define VERSION_MINOR {minor}
#define VERSION_PATCH {patch}
#define VERSION_FULL \"{full}\"
#define VERSION_DESCRIPTION \"{description}\"
#define VERSION_AUTHOR \"{auhtor}\"
#define VERSION_NAME \"{name}\"
"
)
).unwrap();
Build::new().include(out_dir).compile("resources.rc").unwrap();
// println!("cargo:rerun-if-changed=resources.rc"); // windres already does this
//println!("cargo:rerun-if-changed=hank.ico");
println!("cargo:rerun-if-changed=app.manifest");
}
}