Skip to content

Commit d5bdc05

Browse files
committedSep 28, 2024
make Step doc-comments more clear
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 76ed7a1 commit d5bdc05

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed
 

Diff for: ‎src/bootstrap/src/core/builder.rs

+21-17
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,40 @@ impl<'a> Deref for Builder<'a> {
7272
}
7373

7474
pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
75-
/// `PathBuf` when directories are created or to return a `Compiler` once
76-
/// it's been assembled.
75+
/// Result type of `Step::run`.
7776
type Output: Clone;
7877

7978
/// Whether this step is run by default as part of its respective phase.
80-
/// `true` here can still be overwritten by `should_run` calling `default_condition`.
79+
///
80+
/// Note: Even if set to `true`, it can still be overridden (with `default_condition`) by `should_run`.
8181
const DEFAULT: bool = false;
8282

8383
/// If true, then this rule should be skipped if --target was specified, but --host was not
8484
const ONLY_HOSTS: bool = false;
8585

86-
/// Primary function to execute this rule. Can call `builder.ensure()`
87-
/// with other steps to run those.
86+
/// Primary function to implement `Step` logic.
87+
///
88+
/// This function can be triggered in two ways:
89+
/// 1. Directly from bootstrap `Step` handler.
90+
/// 2. Indirectly by being called from other `Step`s using `builder.ensure()`.
8891
///
89-
/// This gets called twice during a normal `./x.py` execution: first
90-
/// with `dry_run() == true`, and then for real.
92+
/// When called directly from bootstrap, this function is called twice:
93+
/// - First in "dry-run" mode to validate certain things (like cyclic Step invocations,
94+
/// directory creation, etc) super quickly.
95+
/// - Then it's called again to run the actual, very expensive process.
96+
///
97+
/// When triggered indirectly from other `Step`s, it may still run twice (as dry-run and real mode)
98+
/// depending on the `Step::run` implementation of the caller.
9199
fn run(self, builder: &Builder<'_>) -> Self::Output;
92100

93-
/// When bootstrap is passed a set of paths, this controls whether this rule
94-
/// will execute. However, it does not get called in a "default" context
95-
/// when we are not passed any paths; in that case, `make_run` is called
96-
/// directly.
101+
/// Determines if this `Step` should be run when given specific paths (e.g., `x build $path`).
102+
/// This is only checked when a path is passed (e.g., `x.py build $path`) and is not run
103+
/// by default without any paths (e.g., `./x.py build`).
97104
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>;
98105

99-
/// Builds up a "root" rule, either as a default rule or from a path passed
100-
/// to us.
101-
///
102-
/// When path is `None`, we are executing in a context where no paths were
103-
/// passed. When `./x.py build` is run, for example, this rule could get
104-
/// called if it is in the correct list below with a path of `None`.
106+
/// Called directly by the bootstrap `Step` handler when not triggered indirectly by other `Step`s using `builder.ensure()`.
107+
/// For example, `./x.py test bootstrap` runs this for `test::Bootstrap`. Similarly, `./x.py test` runs it
108+
/// for every step that is listed by the `describe` macro in `Builder::get_step_descriptions`.
105109
fn make_run(_run: RunConfig<'_>) {
106110
// It is reasonable to not have an implementation of make_run for rules
107111
// who do not want to get called from the root context. This means that

0 commit comments

Comments
 (0)