about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbit-aloo <sshourya17@gmail.com>2025-06-09 20:34:30 +0530
committerbit-aloo <sshourya17@gmail.com>2025-06-09 20:39:48 +0530
commite9ced508f4feeadd9d5b63aa752c1d39dcfbbb6c (patch)
treecd04a6143e18ac8be2cb4de7fd3c783b61f4745e /src
parentf3e1eb1dcade3e846c8624d2db85fc2d11a6d82a (diff)
downloadrust-e9ced508f4feeadd9d5b63aa752c1d39dcfbbb6c.tar.gz
rust-e9ced508f4feeadd9d5b63aa752c1d39dcfbbb6c.zip
remove execution context from flag module and correct the command invocation according to suggestions
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/src/bin/main.rs4
-rw-r--r--src/bootstrap/src/core/config/config.rs16
-rw-r--r--src/bootstrap/src/core/config/flags.rs16
-rw-r--r--src/bootstrap/src/core/download.rs6
-rw-r--r--src/bootstrap/src/utils/channel.rs2
5 files changed, 19 insertions, 25 deletions
diff --git a/src/bootstrap/src/bin/main.rs b/src/bootstrap/src/bin/main.rs
index 9f1fde74359..833f8027951 100644
--- a/src/bootstrap/src/bin/main.rs
+++ b/src/bootstrap/src/bin/main.rs
@@ -29,9 +29,9 @@ fn main() {
     }
 
     debug!("parsing flags");
-    let (flags, exec_ctx) = Flags::parse(&args);
+    let flags = Flags::parse(&args);
     debug!("parsing config based on flags");
-    let config = Config::parse(flags, exec_ctx);
+    let config = Config::parse(flags);
 
     let mut build_lock;
     let _build_lock_guard;
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
index 6b6d9c9e5ba..8d244f438f0 100644
--- a/src/bootstrap/src/core/config/config.rs
+++ b/src/bootstrap/src/core/config/config.rs
@@ -368,7 +368,11 @@ impl Config {
         feature = "tracing",
         instrument(target = "CONFIG_HANDLING", level = "trace", name = "Config::parse", skip_all)
     )]
-    pub fn parse(flags: Flags, exec_ctx: ExecutionContext) -> Config {
+    pub fn parse(flags: Flags) -> Config {
+        let mut exec_ctx = ExecutionContext::new();
+        exec_ctx.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
+        exec_ctx.set_verbose(flags.verbose);
+        exec_ctx.set_fail_fast(flags.cmd.fail_fast());
         Self::parse_inner(flags, Self::get_toml, exec_ctx)
     }
 
@@ -1065,7 +1069,7 @@ impl Config {
 
         let mut git = helpers::git(Some(&self.src));
         git.arg("show").arg(format!("{commit}:{}", file.to_str().unwrap()));
-        git.allow_failure().run_capture_stdout(self).stdout()
+        git.run_capture_stdout(self).stdout()
     }
 
     /// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
@@ -1334,15 +1338,11 @@ impl Config {
         };
 
         // Determine commit checked out in submodule.
-        let checked_out_hash = submodule_git()
-            .allow_failure()
-            .args(["rev-parse", "HEAD"])
-            .run_capture_stdout(self)
-            .stdout();
+        let checked_out_hash =
+            submodule_git().args(["rev-parse", "HEAD"]).run_capture_stdout(self).stdout();
         let checked_out_hash = checked_out_hash.trim_end();
         // Determine commit that the submodule *should* have.
         let recorded = helpers::git(Some(&self.src))
-            .allow_failure()
             .run_always()
             .args(["ls-tree", "HEAD"])
             .arg(relative_path)
diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs
index a50ff4caaf4..bc4fa73a362 100644
--- a/src/bootstrap/src/core/config/flags.rs
+++ b/src/bootstrap/src/core/config/flags.rs
@@ -14,8 +14,7 @@ use crate::core::build_steps::setup::Profile;
 use crate::core::builder::{Builder, Kind};
 use crate::core::config::Config;
 use crate::core::config::target_selection::{TargetSelectionList, target_selection_list};
-use crate::utils::execution_context::ExecutionContext;
-use crate::{Build, DocTests, DryRun};
+use crate::{Build, DocTests};
 
 #[derive(Copy, Clone, Default, Debug, ValueEnum)]
 pub enum Color {
@@ -210,8 +209,8 @@ impl Flags {
             HelpVerboseOnly::try_parse_from(normalize_args(args))
         {
             println!("NOTE: updating submodules before printing available paths");
-            let (flags, exec_ctx) = Self::parse(&[String::from("build")]);
-            let config = Config::parse(flags, exec_ctx);
+            let flags = Self::parse(&[String::from("build")]);
+            let config = Config::parse(flags);
             let build = Build::new(config);
             let paths = Builder::get_help(&build, subcommand);
             if let Some(s) = paths {
@@ -229,13 +228,8 @@ impl Flags {
         feature = "tracing",
         instrument(level = "trace", name = "Flags::parse", skip_all, fields(args = ?args))
     )]
-    pub fn parse(args: &[String]) -> (Self, ExecutionContext) {
-        let mut exec_ctx = ExecutionContext::new();
-        let flags = Flags::parse_from(normalize_args(args));
-        exec_ctx.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
-        exec_ctx.set_verbose(flags.verbose);
-        exec_ctx.set_fail_fast(flags.cmd.fail_fast());
-        (flags, exec_ctx)
+    pub fn parse(args: &[String]) -> Self {
+        Flags::parse_from(normalize_args(args))
     }
 }
 
diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs
index 16d097661b1..f349b9a87ed 100644
--- a/src/bootstrap/src/core/download.rs
+++ b/src/bootstrap/src/core/download.rs
@@ -80,7 +80,7 @@ impl Config {
     /// on NixOS
     fn should_fix_bins_and_dylibs(&self) -> bool {
         let val = *SHOULD_FIX_BINS_AND_DYLIBS.get_or_init(|| {
-            let uname = command("uname").arg("-s").run_capture_stdout(self);
+            let uname = command("uname").allow_failure().arg("-s").run_capture_stdout(self);
             if uname.is_failure() {
                 return false;
             }
@@ -185,7 +185,7 @@ impl Config {
             patchelf.args(["--set-interpreter", dynamic_linker.trim_end()]);
         }
         patchelf.arg(fname);
-        let _ = patchelf.run_capture_stdout(self);
+        let _ = patchelf.allow_failure().run_capture_stdout(self);
     }
 
     fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
@@ -259,7 +259,7 @@ impl Config {
             if self.build.contains("windows-msvc") {
                 eprintln!("Fallback to PowerShell");
                 for _ in 0..3 {
-                    let powershell = command("PowerShell.exe").args([
+                    let powershell = command("PowerShell.exe").allow_failure().args([
                         "/nologo",
                         "-Command",
                         "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;",
diff --git a/src/bootstrap/src/utils/channel.rs b/src/bootstrap/src/utils/channel.rs
index 8bd090e1a01..38f250af42f 100644
--- a/src/bootstrap/src/utils/channel.rs
+++ b/src/bootstrap/src/utils/channel.rs
@@ -46,7 +46,7 @@ impl GitInfo {
 
         let mut git_command = helpers::git(Some(dir));
         git_command.arg("rev-parse");
-        let output = git_command.allow_failure().run_capture_stdout(exec_ctx);
+        let output = git_command.allow_failure().run_capture(exec_ctx);
 
         if output.is_failure() {
             return GitInfo::Absent;