-
Notifications
You must be signed in to change notification settings - Fork 389
/
Copy pathbuild.rs
36 lines (28 loc) · 1003 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
34
35
36
use anyhow::Context;
use std::env;
fn main() -> anyhow::Result<()> {
if cfg!(debug_assertions) {
return Ok(());
}
let target_os = env::var("CARGO_CFG_TARGET_OS").context("Missing 'CARGO_CFG_TARGET_OS")?;
match target_os.as_str() {
"windows" => win_main(),
_ => Ok(()),
}
}
fn win_main() -> anyhow::Result<()> {
use anyhow::Context;
let mut res = winres::WindowsResource::new();
res.set_language(make_lang_id(
windows_sys::Win32::System::SystemServices::LANG_ENGLISH as u16,
windows_sys::Win32::System::SystemServices::SUBLANG_ENGLISH_US as u16,
));
println!("cargo:rerun-if-changed=loader.manifest");
res.set_manifest_file("loader.manifest");
res.set_icon("../dist-assets/icon.ico");
res.compile().context("Failed to compile resources")
}
// Sourced from winnt.h: https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelangid
fn make_lang_id(p: u16, s: u16) -> u16 {
(s << 10) | p
}