2022-10-31 20:08:25 +00:00
|
|
|
// This [build.rs] is for setting Windows icons.
|
|
|
|
// The icon in [File Explorer] gets set here.
|
|
|
|
// The icon in the taskbar and top of the App window gets
|
|
|
|
// set in [src/main.rs, src/constants.rs] at runtime with
|
|
|
|
// pre-compiled bytes using [include_bytes!()] on the images in [images/].
|
2022-12-10 02:00:33 +00:00
|
|
|
#[cfg(windows)]
|
2022-10-31 20:08:25 +00:00
|
|
|
fn main() -> std::io::Result<()> {
|
2024-03-03 08:05:43 +00:00
|
|
|
set_commit_env();
|
2023-11-24 14:30:15 +00:00
|
|
|
|
2024-03-03 08:05:43 +00:00
|
|
|
static_vcruntime::metabuild();
|
|
|
|
let mut res = winres::WindowsResource::new();
|
|
|
|
// This sets the icon.
|
|
|
|
res.set_icon("assets/images/icons/icon.ico");
|
|
|
|
// This sets the [Run as Administrator] metadata flag for Windows.
|
|
|
|
// Why do I do this?: [https://github.com/hinto-janai/gupax/tree/main/src#why-does-gupax-need-to-be-admin-on-windows]
|
|
|
|
// TL;DR: Because Windows.
|
|
|
|
res.set_manifest(
|
|
|
|
r#"
|
2022-12-10 02:00:33 +00:00
|
|
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
|
|
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
|
|
<security>
|
|
|
|
<requestedPrivileges>
|
|
|
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
|
|
|
</requestedPrivileges>
|
|
|
|
</security>
|
|
|
|
</trustInfo>
|
|
|
|
</assembly>
|
2024-03-03 08:05:43 +00:00
|
|
|
"#,
|
|
|
|
);
|
|
|
|
res.compile()
|
2022-10-31 20:08:25 +00:00
|
|
|
}
|
2022-12-10 02:00:33 +00:00
|
|
|
|
|
|
|
#[cfg(unix)]
|
2023-11-24 14:30:15 +00:00
|
|
|
fn main() {
|
2024-03-03 08:05:43 +00:00
|
|
|
set_commit_env();
|
2023-11-24 14:30:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the current git commit to the env var [COMMIT].
|
|
|
|
fn set_commit_env() {
|
2024-03-03 08:05:43 +00:00
|
|
|
println!("cargo:rerun-if-changed=.git/refs/heads/");
|
2023-11-24 14:30:15 +00:00
|
|
|
|
2024-03-03 08:05:43 +00:00
|
|
|
let output = std::process::Command::new("git")
|
|
|
|
.args(["rev-parse", "HEAD"])
|
|
|
|
.output()
|
|
|
|
.unwrap();
|
2023-11-24 14:30:15 +00:00
|
|
|
|
2024-03-03 08:05:43 +00:00
|
|
|
let commit = String::from_utf8(output.stdout).unwrap();
|
2023-11-24 14:30:15 +00:00
|
|
|
|
2024-03-03 08:05:43 +00:00
|
|
|
assert!(commit.len() >= 40);
|
2023-11-24 14:30:15 +00:00
|
|
|
|
2024-03-03 08:05:43 +00:00
|
|
|
println!("cargo:rustc-env=COMMIT={commit}");
|
2023-11-24 14:30:15 +00:00
|
|
|
}
|