compiler/rustc/build.rs RUST 42 lines View on github.com → Search inside
1use std::{env, path};23use rustc_windows_rc::{VersionInfoFileType, compile_windows_resource_file};45fn main() {6    let target_os = env::var("CARGO_CFG_TARGET_OS");7    let target_env = env::var("CARGO_CFG_TARGET_ENV");8    if Ok("windows") == target_os.as_deref() && Ok("msvc") == target_env.as_deref() {9        set_windows_exe_options();10    } else {11        // Avoid rerunning the build script every time.12        println!("cargo:rerun-if-changed=build.rs");13    }14}1516// Add a manifest file to rustc.exe.17fn set_windows_exe_options() {18    set_windows_resource();19    set_windows_manifest();20}2122fn set_windows_resource() {23    let stem = path::PathBuf::from("rustc_main_resource");24    let file_description = "rustc";25    let res_file = compile_windows_resource_file(&stem, file_description, VersionInfoFileType::App);26    println!("cargo:rustc-link-arg={}", res_file.display());27}2829fn set_windows_manifest() {30    static WINDOWS_MANIFEST_FILE: &str = "Windows Manifest.xml";3132    let mut manifest = env::current_dir().unwrap();33    manifest.push(WINDOWS_MANIFEST_FILE);3435    println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}");36    // Embed the Windows application manifest file.37    println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFEST:EMBED");38    println!("cargo:rustc-link-arg-bin=rustc-main=/MANIFESTINPUT:{}", manifest.to_str().unwrap());39    // Turn linker warnings into errors.40    println!("cargo:rustc-link-arg-bin=rustc-main=/WX");41}

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.