Rollup of 5 pull requests by GuillaumeGomez · Pull Request #126824 · rust-lang/rust (original) (raw)

…nur-ozkan

Bootstrap command refactoring: refactor BootstrapCommand (step 1)

This PR is a first step towards https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap.

It refactors BoostrapCommand to get it closer to a state where it is an actual command wrapper that can be routed through a central place of command execution, and also to make the distinction between printing output vs handling output programatically clearer (since now it's a mess).

The existing usages of BootstrapCommand are complicated primarily because of different ways of handling output. There are commands that:

  1. Want to eagerly print stdout/stderr of the executed command, plus print an error message if the command fails (output mode PrintAll). Note that this error message attempts to print stdout/stderr of the command when -v is enabled, but that will always be empty, since this mode uses .status() and not .output().
  2. Want to eagerly print stdout/stderr of the executed command, but do not print any additional error message if it fails (output mode PrintOutput)
  3. Want to capture stdout/stderr of the executed command, but print an error message if it fails (output mode PrintFailure). This means that the user wants to either ignore the output or handle it programatically, but that's not obvious from the name.

The difference between 1) and 2) (unless explicitly specified) is determined dynamically based on the bootstrap verbosity level.

It is very difficult for me to wrap my head around all these modes. I think that in a future PR, we should split these axes into e.g. this:

  1. Do I want to handle the output programmatically or print it to the terminal? This should be a separate axis, true/false. (Note that "hiding the output" essentially just means saying that I handle it programmatically, and then I ignore the output).
  2. Do I want to print a message if the command fails? Yes/No/Based on verbosity (which would be the default).

Then there is also the failure mode, but that is relatively simple to handle, the command execution will just shutdown bootstrap (either eagerly or late) when the command fails.

Note that this is just a first refactoring steps, there are a lot of other things to be done, so some things might not look "final" yet. The next steps are (not necessarily in this order):

Best reviewed commit by commit.

r? @onur-ozkan