Skip to content

Commit 617f00f

Browse files
committed
migrate utils to use new run methods with execution context
1 parent 314e25b commit 617f00f

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

src/bootstrap/src/utils/build_stamp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pub fn generate_smart_stamp_hash(
179179
.allow_failure()
180180
.arg("diff")
181181
.arg(".")
182-
.run_capture_stdout(builder)
182+
.run_capture_stdout(builder.context())
183183
.stdout_if_ok()
184184
.unwrap_or_default();
185185

@@ -190,7 +190,7 @@ pub fn generate_smart_stamp_hash(
190190
.arg("--porcelain")
191191
.arg("-z")
192192
.arg("--untracked-files=normal")
193-
.run_capture_stdout(builder)
193+
.run_capture_stdout(builder.context())
194194
.stdout_if_ok()
195195
.unwrap_or_default();
196196

src/bootstrap/src/utils/cc_detect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ fn default_compiler(
182182
}
183183

184184
let mut cmd = BootstrapCommand::from(c.to_command());
185-
let output = cmd.arg("--version").run_capture_stdout(build).stdout();
185+
let output = cmd.arg("--version").run_capture_stdout(build.context()).stdout();
186186
let i = output.find(" 4.")?;
187187
match output[i + 3..].chars().next().unwrap() {
188188
'0'..='6' => {}
189189
_ => return None,
190190
}
191191
let alternative = format!("e{gnu_compiler}");
192-
if command(&alternative).run_capture(build).is_success() {
192+
if command(&alternative).run_capture(build.context()).is_success() {
193193
Some(PathBuf::from(alternative))
194194
} else {
195195
None

src/bootstrap/src/utils/channel.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use std::fs;
99
use std::path::Path;
1010

11+
use super::execution_context::ExecutionContext;
1112
use super::helpers;
1213
use crate::Build;
1314
use crate::utils::helpers::{start_process, t};
@@ -34,7 +35,7 @@ pub struct Info {
3435
}
3536

3637
impl GitInfo {
37-
pub fn new(omit_git_hash: bool, dir: &Path) -> GitInfo {
38+
pub fn new(omit_git_hash: bool, dir: &Path, execution_context: &ExecutionContext) -> GitInfo {
3839
// See if this even begins to look like a git dir
3940
if !dir.join(".git").exists() {
4041
match read_commit_info_file(dir) {
@@ -43,10 +44,12 @@ impl GitInfo {
4344
}
4445
}
4546

47+
let mut git_command = helpers::git(Some(dir));
48+
git_command.arg("rev-parse");
49+
let output = git_command.run_capture(&execution_context);
4650
// Make sure git commands work
47-
match helpers::git(Some(dir)).arg("rev-parse").as_command_mut().output() {
48-
Ok(ref out) if out.status.success() => {}
49-
_ => return GitInfo::Absent,
51+
if output.is_failure() {
52+
return GitInfo::Absent;
5053
}
5154

5255
// If we're ignoring the git info, we don't actually need to collect it, just make sure this

src/bootstrap/src/utils/helpers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ pub fn get_clang_cl_resource_dir(builder: &Builder<'_>, clang_cl_path: &str) ->
402402
let mut builtins_locator = command(clang_cl_path);
403403
builtins_locator.args(["/clang:-print-libgcc-file-name", "/clang:--rtlib=compiler-rt"]);
404404

405-
let clang_rt_builtins = builtins_locator.run_capture_stdout(builder).stdout();
405+
let clang_rt_builtins = builtins_locator.run_capture_stdout(builder.context()).stdout();
406406
let clang_rt_builtins = Path::new(clang_rt_builtins.trim());
407407
assert!(
408408
clang_rt_builtins.exists(),
@@ -429,7 +429,7 @@ fn lld_flag_no_threads(builder: &Builder<'_>, lld_mode: LldMode, is_windows: boo
429429
LldMode::External => {
430430
let mut cmd = command("lld");
431431
cmd.arg("-flavor").arg("ld").arg("--version");
432-
let out = cmd.run_capture_stdout(builder).stdout();
432+
let out = cmd.run_capture_stdout(builder.context()).stdout();
433433
match (out.find(char::is_numeric), out.find('.')) {
434434
(Some(b), Some(e)) => out.as_str()[b..e].parse::<i32>().ok().unwrap_or(14) > 10,
435435
_ => true,

src/bootstrap/src/utils/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub(crate) mod cc_detect;
88
pub(crate) mod change_tracker;
99
pub(crate) mod channel;
1010
pub(crate) mod exec;
11+
pub(crate) mod execution_context;
1112
pub(crate) mod helpers;
1213
pub(crate) mod job;
1314
pub(crate) mod render_tests;

src/bootstrap/src/utils/tarball.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,12 +393,12 @@ impl<'a> Tarball<'a> {
393393
.arg("log")
394394
.arg("-1")
395395
.arg("--format=%ct")
396-
.run_capture_stdout(self.builder)
396+
.run_capture_stdout(self.builder.context())
397397
.stdout();
398398
cmd.args(["--override-file-mtime", timestamp.trim()]);
399399
}
400400

401-
cmd.run(self.builder);
401+
cmd.run(self.builder.context());
402402

403403
// Ensure there are no symbolic links in the tarball. In particular,
404404
// rustup-toolchain-install-master and most versions of Windows can't handle symbolic links.

0 commit comments

Comments
 (0)