Skip to content

Commit 40dea65

Browse files
committedAug 13, 2017
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.
1 parent 5290c6c commit 40dea65

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed
 

‎config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@
258258
# saying that the FileCheck executable is missing, you may want to disable this.
259259
#codegen-tests = true
260260

261+
# Flag indicating whether git info will be retrieved from .git automatically.
262+
#ignore-git = false
263+
261264
# =============================================================================
262265
# Options for specific targets
263266
#

‎src/bootstrap/channel.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::process::Command;
2121
use build_helper::output;
2222

2323
use Build;
24+
use config::Config;
2425

2526
// The version number
2627
pub const CFG_RELEASE_NUM: &str = "1.21.0";
@@ -41,9 +42,9 @@ struct Info {
4142
}
4243

4344
impl GitInfo {
44-
pub fn new(dir: &Path) -> GitInfo {
45+
pub fn new(config: &Config, dir: &Path) -> GitInfo {
4546
// See if this even begins to look like a git dir
46-
if !dir.join(".git").exists() {
47+
if config.ignore_git || !dir.join(".git").exists() {
4748
return GitInfo { inner: None }
4849
}
4950

‎src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub struct Config {
5454
pub extended: bool,
5555
pub sanitizers: bool,
5656
pub profiler: bool,
57+
pub ignore_git: bool,
5758

5859
pub on_fail: Option<String>,
5960
pub stage: Option<u32>,
@@ -260,6 +261,7 @@ struct Rust {
260261
optimize_tests: Option<bool>,
261262
debuginfo_tests: Option<bool>,
262263
codegen_tests: Option<bool>,
264+
ignore_git: Option<bool>,
263265
}
264266

265267
/// TOML representation of how each build target is configured.
@@ -292,6 +294,7 @@ impl Config {
292294
config.rust_codegen_units = 1;
293295
config.channel = "dev".to_string();
294296
config.codegen_tests = true;
297+
config.ignore_git = false;
295298
config.rust_dist_src = true;
296299

297300
config.on_fail = flags.on_fail;
@@ -410,6 +413,7 @@ impl Config {
410413
set(&mut config.use_jemalloc, rust.use_jemalloc);
411414
set(&mut config.backtrace, rust.backtrace);
412415
set(&mut config.channel, rust.channel.clone());
416+
set(&mut config.ignore_git, rust.ignore_git);
413417
config.rustc_default_linker = rust.default_linker.clone();
414418
config.rustc_default_ar = rust.default_ar.clone();
415419
config.musl_root = rust.musl_root.clone().map(PathBuf::from);

‎src/bootstrap/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ impl Build {
299299
}
300300
None => false,
301301
};
302-
let rust_info = channel::GitInfo::new(&src);
303-
let cargo_info = channel::GitInfo::new(&src.join("src/tools/cargo"));
304-
let rls_info = channel::GitInfo::new(&src.join("src/tools/rls"));
302+
let rust_info = channel::GitInfo::new(&config, &src);
303+
let cargo_info = channel::GitInfo::new(&config, &src.join("src/tools/cargo"));
304+
let rls_info = channel::GitInfo::new(&config, &src.join("src/tools/rls"));
305305

306306
Build {
307307
initial_rustc: config.initial_rustc.clone(),

‎src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl Step for ToolBuild {
109109

110110
cargo.env("CFG_RELEASE_CHANNEL", &build.config.channel);
111111

112-
let info = GitInfo::new(&dir);
112+
let info = GitInfo::new(&build.config, &dir);
113113
if let Some(sha) = info.sha() {
114114
cargo.env("CFG_COMMIT_HASH", sha);
115115
}

0 commit comments

Comments
 (0)
Please sign in to comment.