36 lines
1.4 KiB
Rust
36 lines
1.4 KiB
Rust
// GNU Windows linkers need an explicit normal-user manifest, including tests
|
|
// named "updates", to avoid Windows installer detection. No elevation is needed.
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=../../build/windows_manifest.rs");
|
|
println!("cargo:rerun-if-changed=../../build/windows.manifest");
|
|
println!("cargo:rerun-if-changed=../../build/windows.rc");
|
|
println!("cargo:rerun-if-env-changed=RC");
|
|
let target = std::env::var("TARGET").unwrap_or_default();
|
|
if !target.ends_with("windows-gnu") && !target.ends_with("windows-gnullvm") {
|
|
return;
|
|
}
|
|
let root = std::path::PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap())
|
|
.join("../../build");
|
|
let object = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap())
|
|
.join("normal-user-manifest.o");
|
|
let compiler = std::env::var_os("RC").unwrap_or_else(|| {
|
|
if target.ends_with("gnullvm") {
|
|
"llvm-windres"
|
|
} else {
|
|
"windres"
|
|
}
|
|
.into()
|
|
});
|
|
let result = std::process::Command::new(compiler)
|
|
.current_dir(root)
|
|
.args(["-i", "windows.rc", "-O", "coff", "-o"])
|
|
.arg(&object)
|
|
.status()
|
|
.expect("Windows GNU resource compiler is required (set RC if not on PATH)");
|
|
assert!(
|
|
result.success(),
|
|
"Cannot compile the normal-user Windows manifest"
|
|
);
|
|
println!("cargo:rustc-link-arg={}", object.display());
|
|
}
|