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.
This commit is contained in:
parent
5290c6c8f1
commit
40dea65ec2
@ -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
|
||||
#
|
||||
|
@ -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 }
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ pub struct Config {
|
||||
pub extended: bool,
|
||||
pub sanitizers: bool,
|
||||
pub profiler: bool,
|
||||
pub ignore_git: bool,
|
||||
|
||||
pub on_fail: Option<String>,
|
||||
pub stage: Option<u32>,
|
||||
@ -260,6 +261,7 @@ struct Rust {
|
||||
optimize_tests: Option<bool>,
|
||||
debuginfo_tests: Option<bool>,
|
||||
codegen_tests: Option<bool>,
|
||||
ignore_git: Option<bool>,
|
||||
}
|
||||
|
||||
/// 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);
|
||||
|
@ -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(),
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user