Rollup merge of #124242 - workingjubilee:describe-bootstrap-files-better, r=Mark-Simulacrum

bootstrap: Describe build_steps modules

One of my preferred ways to understand source code is to start with its API. This implies the code is documented reasonably accurately, even if it is a private API. The description of one of these modules had not been updated since 2015 and so was both terse and confusing, so I rewrote it. Then I noticed many others went unremarked, so I offered some remarks.
This commit is contained in:
Matthias Krüger 2024-04-28 01:25:00 +02:00 committed by GitHub
commit f17ce8bf7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 28 additions and 6 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;
@ -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.
@ -41,7 +50,7 @@ pub enum Profile {
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> {
@ -220,7 +229,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"
);

View file

@ -1,3 +1,5 @@
//! Attempt to magically identify good tests to run
#![cfg_attr(feature = "build-metrics", allow(unused))]
use clap::Parser;

View file

@ -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.
use std::env;
use std::ffi::OsStr;

View file

@ -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};