Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: Describe build_steps modules #124242

Merged
merged 9 commits into from
Apr 28, 2024
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/clean.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Implementation of `make clean` in rustbuild.
//! `./x.py clean`
//!
//! Responsible for cleaning out a build directory of all old and stale
//! artifacts to prepare for a fresh build. Currently doesn't remove the
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/core/build_steps/run.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
//! Build-and-run steps for in-repo tools
//!
//! A bit of a hodge-podge as e.g. if a tool's a test fixture it should be in `build_steps::test`.
//! If it can be reached from `./x.py run` it can go here.

use std::path::PathBuf;
use std::process::Command;

Expand Down
13 changes: 11 additions & 2 deletions src/bootstrap/src/core/build_steps/setup.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! First time setup of a dev environment
//!
//! These are build-and-run steps for `./x.py setup`, which allows quickly setting up the directory
//! for modifying, building, and running the compiler and library. Running arbitrary configuration
//! allows setting up things that cannot be simply captured inside the config.toml, in addition to
//! leading people away from manually editing most of the config.toml values.

use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::t;
use crate::utils::change_tracker::CONFIG_CHANGE_HISTORY;
Expand Down Expand Up @@ -25,6 +32,8 @@ pub enum Profile {
None,
}

static PROFILE_DIR: &str = "src/bootstrap/defaults";

/// A list of historical hashes of `src/etc/rust_analyzer_settings.json`.
/// New entries should be appended whenever this is updated so we can detect
/// outdated vs. user-modified settings files.
Expand All @@ -41,7 +50,7 @@ static RUST_ANALYZER_SETTINGS: &str = include_str!("../../../../etc/rust_analyze

impl Profile {
fn include_path(&self, src_path: &Path) -> PathBuf {
PathBuf::from(format!("{}/src/bootstrap/defaults/config.{}.toml", src_path.display(), self))
PathBuf::from(format!("{}/{PROFILE_DIR}/config.{}.toml", src_path.display(), self))
}

pub fn all() -> impl Iterator<Item = Self> {
Expand Down Expand Up @@ -221,7 +230,7 @@ fn setup_config_toml(path: &PathBuf, profile: Profile, config: &Config) {

let latest_change_id = CONFIG_CHANGE_HISTORY.last().unwrap().change_id;
let settings = format!(
"# Includes one of the default files in src/bootstrap/defaults\n\
"# Includes one of the default files in {PROFILE_DIR}\n\
profile = \"{profile}\"\n\
change-id = {latest_change_id}\n"
);
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/build_steps/suggest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Attempt to magically identify good tests to run

#![cfg_attr(feature = "build-metrics", allow(unused))]

use clap::Parser;
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Implementation of the test-related targets of the build system.
//! Build-and-run steps for `./x.py test` test fixtures
//!
//! This file implements the various regression test suites that we execute on
//! our CI.
//! `./x.py test` (aka [`Kind::Test`]) is currently allowed to reach build steps in other modules.
//! However, this contains ~all test parts we expect people to be able to build and run locally.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is true of all Steps, not just test steps - i'm curious why you've singled it out here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if it makes sense to link to src/bootstrap/README and/or https://rustc-dev-guide.rust-lang.org/building/bootstrapping/how-bootstrap-does-it.html in lib.rs and builder.rs respectively.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because most of the things run when you execute ./x.py {command} are in fact in the given {command}.rs, so the fact that this one has an exception stood out to me:

Kind::Test => describe!(
crate::core::build_steps::toolstate::ToolStateCheck,
test::ExpandYamlAnchors,


use std::env;
use std::ffi::OsStr;
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/toolstate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! [Toolstate] checks to keep tools building
//!
//! Reachable via `./x.py test` but mostly relevant for CI, since it isn't run locally by default.
//!
//! [Toolstate]: https://forge.rust-lang.org/infra/toolstate.html

use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::utils::helpers::t;
use serde_derive::{Deserialize, Serialize};
Expand Down
Loading