]> git.lizzy.rs Git - rust.git/blob - compiler/rustc/build.rs
Rollup merge of #103520 - petrochenkov:resout, r=cjgillot
[rust.git] / compiler / rustc / build.rs
1 use std::env;
2
3 fn main() {
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();
8     } else {
9         // Avoid rerunning the build script every time.
10         println!("cargo:rerun-if-changed=build.rs");
11     }
12 }
13
14 // Add a manifest file to rustc.exe.
15 fn set_windows_exe_options() {
16     static WINDOWS_MANIFEST_FILE: &str = "Windows Manifest.xml";
17
18     let mut manifest = env::current_dir().unwrap();
19     manifest.push(WINDOWS_MANIFEST_FILE);
20
21     println!("cargo:rerun-if-changed={}", WINDOWS_MANIFEST_FILE);
22     // Embed the Windows application manifest file.
23     println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFEST:EMBED");
24     println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFESTINPUT:{}", manifest.to_str().unwrap());
25     // Turn linker warnings into errors.
26     println!("cargo:rustc-link-arg-bin=rustc-main=/WX");
27 }