windows: Support compiling with MinGW toolchain (#9815)

Fixes #9757: compile manifest using `embed-manifest` crate, which
supports both MSVC and MinGW

Release Notes:

- N/A
This commit is contained in:
Maksim Bondarenkov 2024-03-26 20:39:39 +03:00 committed by GitHub
parent 35b39e02ce
commit d77cda1ea9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 7 deletions

View file

@ -46,19 +46,18 @@ fn main() {
#[cfg(target_os = "windows")]
{
// todo(windows): This is to avoid stack overflow. Remove it when solved.
println!("cargo:rustc-link-arg=/stack:{}", 8 * 1024 * 1024);
if std::env::var("CARGO_CFG_TARGET_ENV").ok() == Some("msvc".to_string()) {
// todo(windows): This is to avoid stack overflow. Remove it when solved.
println!("cargo:rustc-link-arg=/stack:{}", 8 * 1024 * 1024);
}
let manifest = std::path::Path::new("resources/windows/manifest.xml");
let icon = std::path::Path::new("resources/windows/app-icon.ico");
println!("cargo:rerun-if-changed={}", manifest.display());
println!("cargo:rerun-if-changed={}", icon.display());
println!("cargo:rustc-link-arg-bins=/MANIFEST:EMBED");
println!(
"cargo:rustc-link-arg-bins=/MANIFESTINPUT:{}",
manifest.canonicalize().unwrap().display()
);
embed_manifest::embed_manifest(embed_manifest::new_manifest(manifest.to_str().unwrap()))
.unwrap();
let mut res = winresource::WindowsResource::new();
res.set_icon(icon.to_str().unwrap());