Skip to content

Commit 5b85d74

Browse files
authored
Unrolled build for #142499
Rollup merge of #142499 - Shourya742:2025-06-14-remove-check-run-bootstrap, r=Kobzol Remove check run bootstrap This PR migrates all usage of check_run to new execution context api's. r? `@Kobzol`
2 parents f768dc0 + c9eeeb4 commit 5b85d74

File tree

3 files changed

+19
-50
lines changed

3 files changed

+19
-50
lines changed

src/bootstrap/src/core/config/config.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,12 +1373,13 @@ impl Config {
13731373
}
13741374

13751375
println!("Updating submodule {relative_path}");
1376-
self.check_run(
1377-
helpers::git(Some(&self.src))
1378-
.run_always()
1379-
.args(["submodule", "-q", "sync"])
1380-
.arg(relative_path),
1381-
);
1376+
1377+
helpers::git(Some(&self.src))
1378+
.allow_failure()
1379+
.run_always()
1380+
.args(["submodule", "-q", "sync"])
1381+
.arg(relative_path)
1382+
.run(self);
13821383

13831384
// Try passing `--progress` to start, then run git again without if that fails.
13841385
let update = |progress: bool| {
@@ -1407,26 +1408,23 @@ impl Config {
14071408
git.arg(relative_path);
14081409
git
14091410
};
1410-
if !self.check_run(&mut update(true)) {
1411-
self.check_run(&mut update(false));
1411+
if !update(true).allow_failure().run(self) {
1412+
update(false).allow_failure().run(self);
14121413
}
14131414

14141415
// Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error).
14151416
// diff-index reports the modifications through the exit status
1416-
let has_local_modifications = !self.check_run(submodule_git().allow_failure().args([
1417-
"diff-index",
1418-
"--quiet",
1419-
"HEAD",
1420-
]));
1417+
let has_local_modifications =
1418+
!submodule_git().allow_failure().args(["diff-index", "--quiet", "HEAD"]).run(self);
14211419
if has_local_modifications {
1422-
self.check_run(submodule_git().args(["stash", "push"]));
1420+
submodule_git().allow_failure().args(["stash", "push"]).run(self);
14231421
}
14241422

1425-
self.check_run(submodule_git().args(["reset", "-q", "--hard"]));
1426-
self.check_run(submodule_git().args(["clean", "-qdfx"]));
1423+
submodule_git().allow_failure().args(["reset", "-q", "--hard"]).run(self);
1424+
submodule_git().allow_failure().args(["clean", "-qdfx"]).run(self);
14271425

14281426
if has_local_modifications {
1429-
self.check_run(submodule_git().args(["stash", "pop"]));
1427+
submodule_git().allow_failure().args(["stash", "pop"]).run(self);
14301428
}
14311429
}
14321430

src/bootstrap/src/core/download.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use xz2::bufread::XzDecoder;
99

1010
use crate::core::config::BUILDER_CONFIG_FILENAME;
1111
use crate::utils::build_stamp::BuildStamp;
12-
use crate::utils::exec::{BootstrapCommand, command};
13-
use crate::utils::helpers::{check_run, exe, hex_encode, move_file};
12+
use crate::utils::exec::command;
13+
use crate::utils::helpers::{exe, hex_encode, move_file};
1414
use crate::{Config, t};
1515

1616
static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new();
@@ -65,17 +65,6 @@ impl Config {
6565
tmp
6666
}
6767

68-
/// Runs a command, printing out nice contextual information if it fails.
69-
/// Returns false if do not execute at all, otherwise returns its
70-
/// `status.success()`.
71-
pub(crate) fn check_run(&self, cmd: &mut BootstrapCommand) -> bool {
72-
if self.dry_run() && !cmd.run_always {
73-
return true;
74-
}
75-
self.verbose(|| println!("running: {cmd:?}"));
76-
check_run(cmd, self.is_verbose())
77-
}
78-
7968
/// Whether or not `fix_bin_or_dylib` needs to be run; can only be true
8069
/// on NixOS
8170
fn should_fix_bins_and_dylibs(&self) -> bool {
@@ -214,7 +203,7 @@ impl Config {
214203
// options should be kept in sync with
215204
// src/bootstrap/src/core/download.rs
216205
// for consistency
217-
let mut curl = command("curl");
206+
let mut curl = command("curl").allow_failure();
218207
curl.args([
219208
// follow redirect
220209
"--location",
@@ -255,7 +244,7 @@ impl Config {
255244
curl.arg("--retry-all-errors");
256245
}
257246
curl.arg(url);
258-
if !self.check_run(&mut curl) {
247+
if !curl.run(self) {
259248
if self.host_target.contains("windows-msvc") {
260249
eprintln!("Fallback to PowerShell");
261250
for _ in 0..3 {

src/bootstrap/src/utils/helpers.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,24 +270,6 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>(
270270
}
271271
}
272272

273-
// FIXME: get rid of this function
274-
pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool {
275-
let status = match cmd.as_command_mut().status() {
276-
Ok(status) => status,
277-
Err(e) => {
278-
println!("failed to execute command: {cmd:?}\nERROR: {e}");
279-
return false;
280-
}
281-
};
282-
if !status.success() && print_cmd_on_fail {
283-
println!(
284-
"\n\ncommand did not execute successfully: {cmd:?}\n\
285-
expected success, got: {status}\n\n"
286-
);
287-
}
288-
status.success()
289-
}
290-
291273
pub fn make(host: &str) -> PathBuf {
292274
if host.contains("dragonfly")
293275
|| host.contains("freebsd")

0 commit comments

Comments
 (0)