pub trait Step:
'static
+ Clone
+ Debug
+ PartialEq
+ Eq
+ Hash {
type Output: Clone;
const IS_HOST: bool = false;
// Required methods
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>;
fn run(self, builder: &Builder<'_>) -> Self::Output;
// Provided methods
fn is_default_step(_builder: &Builder<'_>) -> bool { ... }
fn make_run(_run: RunConfig<'_>) { ... }
fn metadata(&self) -> Option<StepMetadata> { ... }
}Provided Associated Constants§
Sourceconst IS_HOST: bool = false
const IS_HOST: bool = false
If this value is true, then the values of run.target passed to the make_run function of
this Step will be determined based on the --host flag.
If this value is false, then they will be determined based on the --target flag.
A corollary of the above is that if this is set to true, then the step will be skipped if
--target was specified, but --host was explicitly set to ‘’ (empty string).
Required Associated Types§
Required Methods§
Sourcefn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>
Called to allow steps to register the command-line paths that should cause them to run.
Sourcefn run(self, builder: &Builder<'_>) -> Self::Output
fn run(self, builder: &Builder<'_>) -> Self::Output
Primary function to implement Step logic.
This function can be triggered in two ways:
- Directly from
Builder::execute_cli. - Indirectly by being called from other
Steps usingBuilder::ensure.
When called with Builder::execute_cli (as done by Build::build), this function is executed twice:
- First in “dry-run” mode to validate certain things (like cyclic Step invocations, directory creation, etc) super quickly.
- Then it’s called again to run the actual, very expensive process.
When triggered indirectly from other Steps, it may still run twice (as dry-run and real mode)
depending on the Step::run implementation of the caller.
Provided Methods§
Sourcefn is_default_step(_builder: &Builder<'_>) -> bool
fn is_default_step(_builder: &Builder<'_>) -> bool
Should this step run when the user invokes bootstrap with a subcommand but no paths/aliases?
For example, ./x test runs all default test steps, and ./x dist
runs all default dist steps.
Most steps are always default or always non-default, and just return true or false. But some steps are conditionally default, based on bootstrap config or the availability of ambient tools.
If the underlying check should not be performed repeatedly (e.g. because it probes command-line tools), consider memoizing its outcome via a field in the builder.
Sourcefn make_run(_run: RunConfig<'_>)
fn make_run(_run: RunConfig<'_>)
Called directly by the bootstrap Step handler when not triggered indirectly by other Steps using Builder::ensure.
For example, ./x.py test bootstrap runs this for test::Bootstrap. Similarly, ./x.py test runs it for every step
that is listed by the describe macro in Builder::get_step_descriptions.
Sourcefn metadata(&self) -> Option<StepMetadata>
fn metadata(&self) -> Option<StepMetadata>
Returns metadata of the step, for tests
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.