diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:25:56 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:25:56 +0000 |
commit | 018c4950b9406055dec02ef0fb52f132e2bb1e2c (patch) | |
tree | a835ebdf2088ef88fa681f8fad45f09922c1ae9a /src/tools/cargo/build.rs | |
parent | Adding debian version 1.75.0+dfsg1-5. (diff) | |
download | rustc-018c4950b9406055dec02ef0fb52f132e2bb1e2c.tar.xz rustc-018c4950b9406055dec02ef0fb52f132e2bb1e2c.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/build.rs')
-rw-r--r-- | src/tools/cargo/build.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/cargo/build.rs b/src/tools/cargo/build.rs index 752221f8c..60fda40e3 100644 --- a/src/tools/cargo/build.rs +++ b/src/tools/cargo/build.rs @@ -7,6 +7,7 @@ use std::process::Command; fn main() { commit_info(); compress_man(); + windows_manifest(); // ALLOWED: Accessing environment during build time shouldn't be prohibited. #[allow(clippy::disallowed_methods)] let target = std::env::var("TARGET").unwrap(); @@ -50,6 +51,14 @@ fn commit_info() { if !Path::new(".git").exists() { return; } + + // Var set by bootstrap whenever omit-git-hash is enabled in rust-lang/rust's config.toml. + println!("cargo:rerun-if-env-changed=CFG_OMIT_GIT_HASH"); + #[allow(clippy::disallowed_methods)] + if std::env::var_os("CFG_OMIT_GIT_HASH").is_some() { + return; + } + let output = match Command::new("git") .arg("log") .arg("-1") @@ -68,3 +77,26 @@ fn commit_info() { println!("cargo:rustc-env=CARGO_COMMIT_SHORT_HASH={}", next()); println!("cargo:rustc-env=CARGO_COMMIT_DATE={}", next()) } + +#[allow(clippy::disallowed_methods)] +fn windows_manifest() { + use std::env; + 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() { + static WINDOWS_MANIFEST_FILE: &str = "windows.manifest.xml"; + + let mut manifest = env::current_dir().unwrap(); + manifest.push(WINDOWS_MANIFEST_FILE); + + println!("cargo:rerun-if-changed={WINDOWS_MANIFEST_FILE}"); + // Embed the Windows application manifest file. + println!("cargo:rustc-link-arg-bin=cargo=/MANIFEST:EMBED"); + println!( + "cargo:rustc-link-arg-bin=cargo=/MANIFESTINPUT:{}", + manifest.to_str().unwrap() + ); + // Turn linker warnings into errors. + println!("cargo:rustc-link-arg-bin=cargo=/WX"); + } +} |