4 let target_os = env::var("CARGO_CFG_TARGET_OS");
5 let target_env = env::var("CARGO_CFG_TARGET_ENV");
6 if Ok("windows") == target_os.as_deref() && Ok("msvc") == target_env.as_deref() {
7 set_windows_exe_options();
11 // Add a manifest file to rustc.exe.
12 fn set_windows_exe_options() {
13 static WINDOWS_MANIFEST_FILE: &str = "Windows Manifest.xml";
15 let mut manifest = env::current_dir().unwrap();
16 manifest.push(WINDOWS_MANIFEST_FILE);
18 println!("cargo:rerun-if-changed={}", WINDOWS_MANIFEST_FILE);
19 // Embed the Windows application manifest file.
20 println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFEST:EMBED");
21 println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFESTINPUT:{}", manifest.to_str().unwrap());
22 // Turn linker warnings into errors.
23 println!("cargo:rustc-link-arg-bin=rustc-main=/WX");