diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2025-06-15 23:51:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-15 23:51:58 +0200 |
| commit | b83fb800a7ffc321c63ec2f716cef3e15ee6f81b (patch) | |
| tree | 183b224549104e5a6c7d5f3b18a3235751dc03a8 /src | |
| parent | 5cce691c5aa606daf355aeb9f3ba471dc6d09f65 (diff) | |
| parent | c9eeeb4b5f6ffe3d6dd72a65aa5a3dc17bfebd2c (diff) | |
| download | rust-b83fb800a7ffc321c63ec2f716cef3e15ee6f81b.tar.gz rust-b83fb800a7ffc321c63ec2f716cef3e15ee6f81b.zip | |
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`
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/core/config/config.rs | 32 | ||||
| -rw-r--r-- | src/bootstrap/src/core/download.rs | 19 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/helpers.rs | 18 |
3 files changed, 19 insertions, 50 deletions
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 970a982dae4..f9980ac5fe1 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1373,12 +1373,13 @@ impl Config { } println!("Updating submodule {relative_path}"); - self.check_run( - helpers::git(Some(&self.src)) - .run_always() - .args(["submodule", "-q", "sync"]) - .arg(relative_path), - ); + + helpers::git(Some(&self.src)) + .allow_failure() + .run_always() + .args(["submodule", "-q", "sync"]) + .arg(relative_path) + .run(self); // Try passing `--progress` to start, then run git again without if that fails. let update = |progress: bool| { @@ -1407,26 +1408,23 @@ impl Config { git.arg(relative_path); git }; - if !self.check_run(&mut update(true)) { - self.check_run(&mut update(false)); + if !update(true).allow_failure().run(self) { + update(false).allow_failure().run(self); } // Save any local changes, but avoid running `git stash pop` if there are none (since it will exit with an error). // diff-index reports the modifications through the exit status - let has_local_modifications = !self.check_run(submodule_git().allow_failure().args([ - "diff-index", - "--quiet", - "HEAD", - ])); + let has_local_modifications = + !submodule_git().allow_failure().args(["diff-index", "--quiet", "HEAD"]).run(self); if has_local_modifications { - self.check_run(submodule_git().args(["stash", "push"])); + submodule_git().allow_failure().args(["stash", "push"]).run(self); } - self.check_run(submodule_git().args(["reset", "-q", "--hard"])); - self.check_run(submodule_git().args(["clean", "-qdfx"])); + submodule_git().allow_failure().args(["reset", "-q", "--hard"]).run(self); + submodule_git().allow_failure().args(["clean", "-qdfx"]).run(self); if has_local_modifications { - self.check_run(submodule_git().args(["stash", "pop"])); + submodule_git().allow_failure().args(["stash", "pop"]).run(self); } } diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index 88a58e580e6..d7c6d8dbcc3 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -9,8 +9,8 @@ use xz2::bufread::XzDecoder; use crate::core::config::BUILDER_CONFIG_FILENAME; use crate::utils::build_stamp::BuildStamp; -use crate::utils::exec::{BootstrapCommand, command}; -use crate::utils::helpers::{check_run, exe, hex_encode, move_file}; +use crate::utils::exec::command; +use crate::utils::helpers::{exe, hex_encode, move_file}; use crate::{Config, t}; static SHOULD_FIX_BINS_AND_DYLIBS: OnceLock<bool> = OnceLock::new(); @@ -65,17 +65,6 @@ impl Config { tmp } - /// Runs a command, printing out nice contextual information if it fails. - /// Returns false if do not execute at all, otherwise returns its - /// `status.success()`. - pub(crate) fn check_run(&self, cmd: &mut BootstrapCommand) -> bool { - if self.dry_run() && !cmd.run_always { - return true; - } - self.verbose(|| println!("running: {cmd:?}")); - check_run(cmd, self.is_verbose()) - } - /// Whether or not `fix_bin_or_dylib` needs to be run; can only be true /// on NixOS fn should_fix_bins_and_dylibs(&self) -> bool { @@ -214,7 +203,7 @@ impl Config { // options should be kept in sync with // src/bootstrap/src/core/download.rs // for consistency - let mut curl = command("curl"); + let mut curl = command("curl").allow_failure(); curl.args([ // follow redirect "--location", @@ -255,7 +244,7 @@ impl Config { curl.arg("--retry-all-errors"); } curl.arg(url); - if !self.check_run(&mut curl) { + if !curl.run(self) { if self.host_target.contains("windows-msvc") { eprintln!("Fallback to PowerShell"); for _ in 0..3 { diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 3e04e046844..8b2f2dd431e 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -270,24 +270,6 @@ pub fn is_valid_test_suite_arg<'a, P: AsRef<Path>>( } } -// FIXME: get rid of this function -pub fn check_run(cmd: &mut BootstrapCommand, print_cmd_on_fail: bool) -> bool { - let status = match cmd.as_command_mut().status() { - Ok(status) => status, - Err(e) => { - println!("failed to execute command: {cmd:?}\nERROR: {e}"); - return false; - } - }; - if !status.success() && print_cmd_on_fail { - println!( - "\n\ncommand did not execute successfully: {cmd:?}\n\ - expected success, got: {status}\n\n" - ); - } - status.success() -} - pub fn make(host: &str) -> PathBuf { if host.contains("dragonfly") || host.contains("freebsd") |
