-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
57 lines (50 loc) · 2.09 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
#[path = "src/resources.rs"]
mod resources;
use std::env;
use resources::*;
use winresource::WindowsResource;
const MANIFEST: &str = r#"<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="?NAME?" version="?VERSION?" />
<trustInfo xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2</dpiAwareness>
<heapType xmlns="http://schemas.microsoft.com/SMI/2020/WindowsSettings">SegmentHeap</heapType>
</windowsSettings>
</application>
</assembly>"#;
fn main() {
// Update manifest with package name and version from Cargo.toml.
let name = env::var("CARGO_PKG_NAME").unwrap();
let version = [
env::var("CARGO_PKG_VERSION_MAJOR").unwrap(),
env::var("CARGO_PKG_VERSION_MINOR").unwrap(),
env::var("CARGO_PKG_VERSION_PATCH").unwrap(),
"0".to_string(),
]
.join(".");
let manifest = MANIFEST.to_string();
let manifest = manifest.replace("?NAME?", &name);
let manifest = manifest.replace("?VERSION?", &version);
// Minimize XML
let manifest = manifest.replace('\r', "");
let manifest = manifest.replace('\n', "");
let manifest = manifest.replace(" ", "");
WindowsResource::new()
.set_manifest(&manifest)
.set_icon_with_id("icons/keyboard.ico", &format!("{}", ICON_KEYBOARD)) // icon for the .exe file
.set_icon_with_id(
"icons/keyboard_delete.ico",
&format!("{}", ICON_KEYBOARD_DELETE),
)
.compile()
.unwrap();
}