From 40dea65ec2675f776a27b67fcb2bb7f29e843da9 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 3 Aug 2017 10:53:56 -0600 Subject: [PATCH] Add ability to ignore git when building rust. Some users of the build system change the git sha on every build due to utilizing git to push changes to a remote server. This allows them to simply configure that away instead of depending on custom patches to rustbuild. --- config.toml.example | 3 +++ src/bootstrap/channel.rs | 5 +++-- src/bootstrap/config.rs | 4 ++++ src/bootstrap/lib.rs | 6 +++--- src/bootstrap/tool.rs | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/config.toml.example b/config.toml.example index 19678dc7793..962be2e6085 100644 --- a/config.toml.example +++ b/config.toml.example @@ -258,6 +258,9 @@ # saying that the FileCheck executable is missing, you may want to disable this. #codegen-tests = true +# Flag indicating whether git info will be retrieved from .git automatically. +#ignore-git = false + # ============================================================================= # Options for specific targets # diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index beefaeab90b..9c1ae83d382 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -21,6 +21,7 @@ use std::process::Command; use build_helper::output; use Build; +use config::Config; // The version number pub const CFG_RELEASE_NUM: &str = "1.21.0"; @@ -41,9 +42,9 @@ struct Info { } impl GitInfo { - pub fn new(dir: &Path) -> GitInfo { + pub fn new(config: &Config, dir: &Path) -> GitInfo { // See if this even begins to look like a git dir - if !dir.join(".git").exists() { + if config.ignore_git || !dir.join(".git").exists() { return GitInfo { inner: None } } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 008dbbe8914..3ec1c205dc0 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -54,6 +54,7 @@ pub struct Config { pub extended: bool, pub sanitizers: bool, pub profiler: bool, + pub ignore_git: bool, pub on_fail: Option, pub stage: Option, @@ -260,6 +261,7 @@ struct Rust { optimize_tests: Option, debuginfo_tests: Option, codegen_tests: Option, + ignore_git: Option, } /// TOML representation of how each build target is configured. @@ -292,6 +294,7 @@ impl Config { config.rust_codegen_units = 1; config.channel = "dev".to_string(); config.codegen_tests = true; + config.ignore_git = false; config.rust_dist_src = true; config.on_fail = flags.on_fail; @@ -410,6 +413,7 @@ impl Config { set(&mut config.use_jemalloc, rust.use_jemalloc); set(&mut config.backtrace, rust.backtrace); set(&mut config.channel, rust.channel.clone()); + set(&mut config.ignore_git, rust.ignore_git); config.rustc_default_linker = rust.default_linker.clone(); config.rustc_default_ar = rust.default_ar.clone(); config.musl_root = rust.musl_root.clone().map(PathBuf::from); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index e1d2779057f..1452a38f6ed 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -299,9 +299,9 @@ impl Build { } None => false, }; - let rust_info = channel::GitInfo::new(&src); - let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo")); - let rls_info = channel::GitInfo::new(&src.join("src/tools/rls")); + let rust_info = channel::GitInfo::new(&config, &src); + let cargo_info = channel::GitInfo::new(&config, &src.join("src/tools/cargo")); + let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls")); Build { initial_rustc: config.initial_rustc.clone(), diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 862b3e2b1ed..da61ad44289 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -109,7 +109,7 @@ impl Step for ToolBuild { cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel); - let info = GitInfo::new(&dir); + let info = GitInfo::new(&build.config, &dir); if let Some(sha) = info.sha() { cargo.env("CFG_COMMIT_HASH", sha); }