Skip to content

Commit

Permalink
fix: correct path for icon windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrix126 committed Mar 3, 2024
1 parent 86d1dae commit 9b8e9a2
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
// pre-compiled bytes using [include_bytes!()] on the images in [images/].
#[cfg(windows)]
fn main() -> std::io::Result<()> {
set_commit_env();
set_commit_env();

static_vcruntime::metabuild();
let mut res = winres::WindowsResource::new();
// This sets the icon.
res.set_icon("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#"
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#"
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
Expand All @@ -24,27 +25,28 @@ fn main() -> std::io::Result<()> {
</security>
</trustInfo>
</assembly>
"#);
res.compile()
"#,
);
res.compile()
}

#[cfg(unix)]
fn main() {
set_commit_env();
set_commit_env();
}

// Set the current git commit to the env var [COMMIT].
fn set_commit_env() {
println!("cargo:rerun-if-changed=.git/refs/heads/");
println!("cargo:rerun-if-changed=.git/refs/heads/");

let output = std::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
let output = std::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.unwrap();

let commit = String::from_utf8(output.stdout).unwrap();
let commit = String::from_utf8(output.stdout).unwrap();

assert!(commit.len() >= 40);
assert!(commit.len() >= 40);

println!("cargo:rustc-env=COMMIT={commit}");
println!("cargo:rustc-env=COMMIT={commit}");
}

0 comments on commit 9b8e9a2

Please sign in to comment.