Skip to content

Commit e9ced50

Browse files
committed
remove execution context from flag module and correct the command invocation according to suggestions
1 parent f3e1eb1 commit e9ced50

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

src/bootstrap/src/bin/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ fn main() {
2929
}
3030

3131
debug!("parsing flags");
32-
let (flags, exec_ctx) = Flags::parse(&args);
32+
let flags = Flags::parse(&args);
3333
debug!("parsing config based on flags");
34-
let config = Config::parse(flags, exec_ctx);
34+
let config = Config::parse(flags);
3535

3636
let mut build_lock;
3737
let _build_lock_guard;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ impl Config {
368368
feature = "tracing",
369369
instrument(target = "CONFIG_HANDLING", level = "trace", name = "Config::parse", skip_all)
370370
)]
371-
pub fn parse(flags: Flags, exec_ctx: ExecutionContext) -> Config {
371+
pub fn parse(flags: Flags) -> Config {
372+
let mut exec_ctx = ExecutionContext::new();
373+
exec_ctx.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
374+
exec_ctx.set_verbose(flags.verbose);
375+
exec_ctx.set_fail_fast(flags.cmd.fail_fast());
372376
Self::parse_inner(flags, Self::get_toml, exec_ctx)
373377
}
374378

@@ -1065,7 +1069,7 @@ impl Config {
10651069

10661070
let mut git = helpers::git(Some(&self.src));
10671071
git.arg("show").arg(format!("{commit}:{}", file.to_str().unwrap()));
1068-
git.allow_failure().run_capture_stdout(self).stdout()
1072+
git.run_capture_stdout(self).stdout()
10691073
}
10701074

10711075
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
@@ -1334,15 +1338,11 @@ impl Config {
13341338
};
13351339

13361340
// Determine commit checked out in submodule.
1337-
let checked_out_hash = submodule_git()
1338-
.allow_failure()
1339-
.args(["rev-parse", "HEAD"])
1340-
.run_capture_stdout(self)
1341-
.stdout();
1341+
let checked_out_hash =
1342+
submodule_git().args(["rev-parse", "HEAD"]).run_capture_stdout(self).stdout();
13421343
let checked_out_hash = checked_out_hash.trim_end();
13431344
// Determine commit that the submodule *should* have.
13441345
let recorded = helpers::git(Some(&self.src))
1345-
.allow_failure()
13461346
.run_always()
13471347
.args(["ls-tree", "HEAD"])
13481348
.arg(relative_path)

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use crate::core::build_steps::setup::Profile;
1414
use crate::core::builder::{Builder, Kind};
1515
use crate::core::config::Config;
1616
use crate::core::config::target_selection::{TargetSelectionList, target_selection_list};
17-
use crate::utils::execution_context::ExecutionContext;
18-
use crate::{Build, DocTests, DryRun};
17+
use crate::{Build, DocTests};
1918

2019
#[derive(Copy, Clone, Default, Debug, ValueEnum)]
2120
pub enum Color {
@@ -210,8 +209,8 @@ impl Flags {
210209
HelpVerboseOnly::try_parse_from(normalize_args(args))
211210
{
212211
println!("NOTE: updating submodules before printing available paths");
213-
let (flags, exec_ctx) = Self::parse(&[String::from("build")]);
214-
let config = Config::parse(flags, exec_ctx);
212+
let flags = Self::parse(&[String::from("build")]);
213+
let config = Config::parse(flags);
215214
let build = Build::new(config);
216215
let paths = Builder::get_help(&build, subcommand);
217216
if let Some(s) = paths {
@@ -229,13 +228,8 @@ impl Flags {
229228
feature = "tracing",
230229
instrument(level = "trace", name = "Flags::parse", skip_all, fields(args = ?args))
231230
)]
232-
pub fn parse(args: &[String]) -> (Self, ExecutionContext) {
233-
let mut exec_ctx = ExecutionContext::new();
234-
let flags = Flags::parse_from(normalize_args(args));
235-
exec_ctx.set_dry_run(if flags.dry_run { DryRun::UserSelected } else { DryRun::Disabled });
236-
exec_ctx.set_verbose(flags.verbose);
237-
exec_ctx.set_fail_fast(flags.cmd.fail_fast());
238-
(flags, exec_ctx)
231+
pub fn parse(args: &[String]) -> Self {
232+
Flags::parse_from(normalize_args(args))
239233
}
240234
}
241235

src/bootstrap/src/core/download.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Config {
8080
/// on NixOS
8181
fn should_fix_bins_and_dylibs(&self) -> bool {
8282
let val = *SHOULD_FIX_BINS_AND_DYLIBS.get_or_init(|| {
83-
let uname = command("uname").arg("-s").run_capture_stdout(self);
83+
let uname = command("uname").allow_failure().arg("-s").run_capture_stdout(self);
8484
if uname.is_failure() {
8585
return false;
8686
}
@@ -185,7 +185,7 @@ impl Config {
185185
patchelf.args(["--set-interpreter", dynamic_linker.trim_end()]);
186186
}
187187
patchelf.arg(fname);
188-
let _ = patchelf.run_capture_stdout(self);
188+
let _ = patchelf.allow_failure().run_capture_stdout(self);
189189
}
190190

191191
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
@@ -259,7 +259,7 @@ impl Config {
259259
if self.build.contains("windows-msvc") {
260260
eprintln!("Fallback to PowerShell");
261261
for _ in 0..3 {
262-
let powershell = command("PowerShell.exe").args([
262+
let powershell = command("PowerShell.exe").allow_failure().args([
263263
"/nologo",
264264
"-Command",
265265
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;",

src/bootstrap/src/utils/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl GitInfo {
4646

4747
let mut git_command = helpers::git(Some(dir));
4848
git_command.arg("rev-parse");
49-
let output = git_command.allow_failure().run_capture_stdout(exec_ctx);
49+
let output = git_command.allow_failure().run_capture(exec_ctx);
5050

5151
if output.is_failure() {
5252
return GitInfo::Absent;

0 commit comments

Comments
 (0)