How Bootstrap does it
The core concept in Bootstrap is a build Step, which are chained together
by Builder::ensure. Builder::ensure takes a Step as input, and runs
the Step if and only if it has not already been run. Let's take a closer
look at Step.
Synopsis of Step
A Step represents a granular collection of actions involved in the process
of producing some artifact. It can be thought of like a rule in Makefiles.
The Step trait is defined as:
pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
type Output: Clone;
const DEFAULT: bool = false;
const ONLY_HOSTS: bool = false;
// Required methods
fn run(self, builder: &Builder<'_>) -> Self::Output;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>;
// Provided method
fn make_run(_run: RunConfig<'_>) { ... }
}
runis the function that is responsible for doing the work.Builder::ensureinvokesrun.should_runis the command-line interface, which determines if an invocation such asx build fooshould run a givenStep. In a "default" context where no paths are provided, thenmake_runis called directly.make_runis invoked only for things directly asked via the CLI and not for steps which are dependencies of other steps.
The entry points
There's a couple of preliminary steps before core Bootstrap code is reached:
- Shell script or
make:./xor./x.ps1ormake - Convenience wrapper script:
x.py src/bootstrap/bootstrap.pysrc/bootstrap/src/bin/main.rs
See src/bootstrap/README.md for a more specific description of the implementation details.