Skip to content

Commit bff4cca

Browse files
committed
respect rust-lang/rust's omit-git-hash
The config.toml file in rust-lang/rust has the omit-git-hash option, which prevents git information from being embedded into binaries. This works for most tools, as they rely on the git information provided by bootstrap through environment variables. Cargo does its own git detection in its build script though, which didn't adhere to to that option. This changes that by skipping git detection whenever bootstrap signals the option is enabled.
1 parent 2cbbf6e commit bff4cca

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ fn commit_info() {
5050
if !Path::new(".git").exists() {
5151
return;
5252
}
53+
54+
// Var set by bootstrap whenever omit-git-hash is enabled in rust-lang/rust's config.toml.
55+
println!("cargo:rerun-if-env-changed=CFG_OMIT_GIT_HASH");
56+
#[allow(clippy::disallowed-methods)]
57+
if std::env::var_os("CFG_OMIT_GIT_HASH").is_some() {
58+
return;
59+
}
60+
5361
let output = match Command::new("git")
5462
.arg("log")
5563
.arg("-1")

0 commit comments

Comments
 (0)