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
5 changed files with 14 additions and 6 deletions
|
@ -258,6 +258,9 @@
|
||||||
# saying that the FileCheck executable is missing, you may want to disable this.
|
# saying that the FileCheck executable is missing, you may want to disable this.
|
||||||
#codegen-tests = true
|
#codegen-tests = true
|
||||||
|
|
||||||
|
# Flag indicating whether git info will be retrieved from .git automatically.
|
||||||
|
#ignore-git = false
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Options for specific targets
|
# Options for specific targets
|
||||||
#
|
#
|
||||||
|
|
|
@ -21,6 +21,7 @@ use std::process::Command;
|
||||||
use build_helper::output;
|
use build_helper::output;
|
||||||
|
|
||||||
use Build;
|
use Build;
|
||||||
|
use config::Config;
|
||||||
|
|
||||||
// The version number
|
// The version number
|
||||||
pub const CFG_RELEASE_NUM: &str = "1.21.0";
|
pub const CFG_RELEASE_NUM: &str = "1.21.0";
|
||||||
|
@ -41,9 +42,9 @@ struct Info {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GitInfo {
|
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
|
// 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 }
|
return GitInfo { inner: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ pub struct Config {
|
||||||
pub extended: bool,
|
pub extended: bool,
|
||||||
pub sanitizers: bool,
|
pub sanitizers: bool,
|
||||||
pub profiler: bool,
|
pub profiler: bool,
|
||||||
|
pub ignore_git: bool,
|
||||||
|
|
||||||
pub on_fail: Option<String>,
|
pub on_fail: Option<String>,
|
||||||
pub stage: Option<u32>,
|
pub stage: Option<u32>,
|
||||||
|
@ -260,6 +261,7 @@ struct Rust {
|
||||||
optimize_tests: Option<bool>,
|
optimize_tests: Option<bool>,
|
||||||
debuginfo_tests: Option<bool>,
|
debuginfo_tests: Option<bool>,
|
||||||
codegen_tests: Option<bool>,
|
codegen_tests: Option<bool>,
|
||||||
|
ignore_git: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TOML representation of how each build target is configured.
|
/// TOML representation of how each build target is configured.
|
||||||
|
@ -292,6 +294,7 @@ impl Config {
|
||||||
config.rust_codegen_units = 1;
|
config.rust_codegen_units = 1;
|
||||||
config.channel = "dev".to_string();
|
config.channel = "dev".to_string();
|
||||||
config.codegen_tests = true;
|
config.codegen_tests = true;
|
||||||
|
config.ignore_git = false;
|
||||||
config.rust_dist_src = true;
|
config.rust_dist_src = true;
|
||||||
|
|
||||||
config.on_fail = flags.on_fail;
|
config.on_fail = flags.on_fail;
|
||||||
|
@ -410,6 +413,7 @@ impl Config {
|
||||||
set(&mut config.use_jemalloc, rust.use_jemalloc);
|
set(&mut config.use_jemalloc, rust.use_jemalloc);
|
||||||
set(&mut config.backtrace, rust.backtrace);
|
set(&mut config.backtrace, rust.backtrace);
|
||||||
set(&mut config.channel, rust.channel.clone());
|
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_linker = rust.default_linker.clone();
|
||||||
config.rustc_default_ar = rust.default_ar.clone();
|
config.rustc_default_ar = rust.default_ar.clone();
|
||||||
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
|
||||||
|
|
|
@ -299,9 +299,9 @@ impl Build {
|
||||||
}
|
}
|
||||||
None => false,
|
None => false,
|
||||||
};
|
};
|
||||||
let rust_info = channel::GitInfo::new(&src);
|
let rust_info = channel::GitInfo::new(&config, &src);
|
||||||
let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo"));
|
let cargo_info = channel::GitInfo::new(&config, &src.join("src/tools/cargo"));
|
||||||
let rls_info = channel::GitInfo::new(&src.join("src/tools/rls"));
|
let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls"));
|
||||||
|
|
||||||
Build {
|
Build {
|
||||||
initial_rustc: config.initial_rustc.clone(),
|
initial_rustc: config.initial_rustc.clone(),
|
||||||
|
|
|
@ -109,7 +109,7 @@ impl Step for ToolBuild {
|
||||||
|
|
||||||
cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel);
|
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() {
|
if let Some(sha) = info.sha() {
|
||||||
cargo.env("CFG_COMMIT_HASH", sha);
|
cargo.env("CFG_COMMIT_HASH", sha);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue