diff options
| author | Aleksey Kliger <alklig@microsoft.com> | 2025-08-18 16:42:21 -0400 |
|---|---|---|
| committer | Aleksey Kliger <alklig@microsoft.com> | 2025-09-05 14:06:31 -0400 |
| commit | 095fa86a3ba30f4198c88ef300354391d3ab97e1 (patch) | |
| tree | 6494c2a99450b4fa4a935bd46bc6b246c5b26357 /compiler/rustc_driver | |
| parent | fe55364329579d361b1ab565728bc033a7dba07e (diff) | |
| download | rust-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_driver')
| -rw-r--r-- | compiler/rustc_driver/Cargo.toml | 5 | ||||
| -rw-r--r-- | compiler/rustc_driver/build.rs | 21 |
2 files changed, 26 insertions, 0 deletions
diff --git a/compiler/rustc_driver/Cargo.toml b/compiler/rustc_driver/Cargo.toml index e3ee8351295..51909719827 100644 --- a/compiler/rustc_driver/Cargo.toml +++ b/compiler/rustc_driver/Cargo.toml @@ -10,3 +10,8 @@ crate-type = ["dylib"] # tidy-alphabetical-start rustc_driver_impl = { path = "../rustc_driver_impl" } # tidy-alphabetical-end + +[build-dependencies] +# tidy-alphabetical-start +rustc_windows_rc = { path = "../rustc_windows_rc" } +# tidy-alphabetical-end diff --git a/compiler/rustc_driver/build.rs b/compiler/rustc_driver/build.rs new file mode 100644 index 00000000000..ba44fe7a86e --- /dev/null +++ b/compiler/rustc_driver/build.rs @@ -0,0 +1,21 @@ +use std::{env, path}; + +use rustc_windows_rc::{VersionInfoFileType, compile_windows_resource_file}; + +fn main() { + let target_os = env::var("CARGO_CFG_TARGET_OS"); + let target_env = env::var("CARGO_CFG_TARGET_ENV"); + if Ok("windows") == target_os.as_deref() && Ok("msvc") == target_env.as_deref() { + set_windows_dll_options(); + } else { + // Avoid rerunning the build script every time. + println!("cargo:rerun-if-changed=build.rs"); + } +} + +fn set_windows_dll_options() { + let stem = path::PathBuf::from("rustc_driver_resource"); + let file_description = "rustc_driver"; + let res_file = compile_windows_resource_file(&stem, file_description, VersionInfoFileType::Dll); + println!("cargo:rustc-link-arg={}", res_file.display()); +} |
