about summary refs log tree commit diff
path: root/compiler/rustc
diff options
context:
space:
mode:
authorAleksey Kliger <alklig@microsoft.com>2025-08-18 16:42:21 -0400
committerAleksey Kliger <alklig@microsoft.com>2025-09-05 14:06:31 -0400
commit095fa86a3ba30f4198c88ef300354391d3ab97e1 (patch)
tree6494c2a99450b4fa4a935bd46bc6b246c5b26357 /compiler/rustc
parentfe55364329579d361b1ab565728bc033a7dba07e (diff)
downloadrust-095fa86a3ba30f4198c88ef300354391d3ab97e1.tar.gz
rust-095fa86a3ba30f4198c88ef300354391d3ab97e1.zip
compiler: Add Windows resources to rustc-main and rustc_driver
Adds Windows resources with the rust version information to rustc-main.exe and rustc_driver.dll

Sets the product description to "Rust Compiler" or "Rust Compiler (channel)" for non-stable channels
Diffstat (limited to 'compiler/rustc')
-rw-r--r--compiler/rustc/Cargo.toml5
-rw-r--r--compiler/rustc/build.rs16
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/rustc/Cargo.toml b/compiler/rustc/Cargo.toml
index 3ca75235446..e3214d1ab9c 100644
--- a/compiler/rustc/Cargo.toml
+++ b/compiler/rustc/Cargo.toml
@@ -33,3 +33,8 @@ llvm = ['rustc_driver_impl/llvm']
 max_level_info = ['rustc_driver_impl/max_level_info']
 rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']
 # tidy-alphabetical-end
+
+[build-dependencies]
+# tidy-alphabetical-start
+rustc_windows_rc = { path = "../rustc_windows_rc" }
+# tidy-alphabetical-end
diff --git a/compiler/rustc/build.rs b/compiler/rustc/build.rs
index 8b7d28d2b8a..9b5def53e3c 100644
--- a/compiler/rustc/build.rs
+++ b/compiler/rustc/build.rs
@@ -1,4 +1,6 @@
-use std::env;
+use std::{env, path};
+
+use rustc_windows_rc::{VersionInfoFileType, compile_windows_resource_file};
 
 fn main() {
     let target_os = env::var("CARGO_CFG_TARGET_OS");
@@ -13,6 +15,18 @@ fn main() {
 
 // Add a manifest file to rustc.exe.
 fn set_windows_exe_options() {
+    set_windows_resource();
+    set_windows_manifest();
+}
+
+fn set_windows_resource() {
+    let stem = path::PathBuf::from("rustc_main_resource");
+    let file_description = "rustc";
+    let res_file = compile_windows_resource_file(&stem, file_description, VersionInfoFileType::App);
+    println!("cargo:rustc-link-arg={}", res_file.display());
+}
+
+fn set_windows_manifest() {
     static WINDOWS_MANIFEST_FILE: &str = "Windows Manifest.xml";
 
     let mut manifest = env::current_dir().unwrap();