diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index f083e0416fcea..aebdc2a6a92a3 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -37,7 +37,6 @@ impl Std { impl Step for Std { type Output = BuildStamp; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let mut run = run; @@ -48,6 +47,10 @@ impl Step for Std { run.path("library") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { if !run.builder.download_rustc() && run.builder.config.skip_std_check_if_no_download_rustc { eprintln!( @@ -310,12 +313,15 @@ impl Rustc { impl Step for Rustc { type Output = BuildStamp; const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.crate_or_deps("rustc-main").path("compiler") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let crates = run.make_run_crates(Alias::Compiler); run.builder.ensure(Rustc::new(run.builder, run.target, crates)); @@ -510,14 +516,16 @@ pub struct CraneliftCodegenBackend { impl Step for CraneliftCodegenBackend { type Output = (); - const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rustc_codegen_cranelift").alias("cg_clif") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(CraneliftCodegenBackend { build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Codegen), @@ -580,14 +588,16 @@ pub struct GccCodegenBackend { impl Step for GccCodegenBackend { type Output = (); - const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rustc_codegen_gcc").alias("cg_gcc") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(GccCodegenBackend { build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Codegen), @@ -665,13 +675,16 @@ macro_rules! tool_check_step { impl Step for $name { type Output = (); const IS_HOST: bool = true; - /// Most of the tool-checks using this macro are run by default. - const DEFAULT: bool = true $( && $default )?; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.paths(&[ $path, $( $alt_path ),* ]) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + // Most of the tool-checks using this macro are run by default. + true $( && const { $default } )? + } + fn make_run(run: RunConfig<'_>) { let target = run.target; let mode: Mode = $mode; diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index 8712aeb81eb88..6dc03236053c7 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -18,9 +18,17 @@ use crate::{Build, Compiler, Kind, Mode, Subcommand}; pub struct CleanAll {} impl Step for CleanAll { - const DEFAULT: bool = true; type Output = (); + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + // Only runs as the default `./x clean` step; cannot be selected explicitly. + run.never() + } + + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(CleanAll {}) } @@ -36,10 +44,6 @@ impl Step for CleanAll { clean(builder.build, all, stage) } - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.never() // handled by DEFAULT - } } macro_rules! clean_crate_tree { diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index 290a00aa3c13a..d8b74b43cfab8 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -170,12 +170,15 @@ impl Std { impl Step for Std { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.crate_or_deps("sysroot").path("library") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let crates = std_crates_for_run_make(&run); let config = LintConfig::new(run.builder); @@ -253,12 +256,15 @@ impl Rustc { impl Step for Rustc { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.crate_or_deps("rustc-main").path("compiler") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let crates = run.make_run_crates(Alias::Compiler); @@ -398,7 +404,7 @@ macro_rules! lint_any { $path:expr, $readable_name:expr, $mode:expr - $(,lint_by_default = $lint_by_default:expr)* + $(, lint_by_default = $lint_by_default:expr )? ; )+) => { $( @@ -412,12 +418,15 @@ macro_rules! lint_any { impl Step for $name { type Output = (); - const DEFAULT: bool = if false $(|| $lint_by_default)* { true } else { false }; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path($path) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false $( || const { $lint_by_default } )? + } + fn make_run(run: RunConfig<'_>) { let config = LintConfig::new(run.builder); run.builder.ensure($name { @@ -510,12 +519,15 @@ pub struct CI { impl Step for CI { type Output = (); - const DEFAULT: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("ci") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + fn make_run(run: RunConfig<'_>) { let config = LintConfig::new(run.builder); run.builder.ensure(CI { target: run.target, config }); diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 6857a40ada81b..fa916258a18f2 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -113,12 +113,14 @@ impl Step for Std { /// Build stamp of std, if it was indeed built or uplifted. type Output = Option; - const DEFAULT: bool = true; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.crate_or_deps("sysroot").path("library") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let crates = std_crates_for_run_make(&run); let builder = run.builder; @@ -1011,9 +1013,7 @@ impl Rustc { impl Step for Rustc { type Output = BuiltRustc; - const IS_HOST: bool = true; - const DEFAULT: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { let mut crates = run.builder.in_tree_crates("rustc-main", None); @@ -1028,6 +1028,10 @@ impl Step for Rustc { run.crates(crates) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + fn make_run(run: RunConfig<'_>) { // If only `compiler` was passed, do not run this step. // Instead the `Assemble` step will take care of compiling Rustc. diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 58d89ce9662a3..0c6a929fdd62e 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -63,11 +63,13 @@ pub struct Docs { impl Step for Docs { type Output = Option; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = run.builder.config.docs; - run.alias("rust-docs").default_condition(default) + run.alias("rust-docs") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -107,11 +109,13 @@ pub struct JsonDocs { impl Step for JsonDocs { type Output = Option; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = run.builder.config.docs; - run.alias("rust-docs-json").default_condition(default) + run.alias("rust-docs-json") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -156,13 +160,14 @@ pub struct RustcDocs { impl Step for RustcDocs { type Output = GeneratedTarball; - - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.alias("rustc-docs").default_condition(builder.config.compiler_docs) + run.alias("rustc-docs") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.compiler_docs } fn make_run(run: RunConfig<'_>) { @@ -382,12 +387,15 @@ pub struct Mingw { impl Step for Mingw { type Output = Option; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rust-mingw") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Mingw { target: run.target }); } @@ -428,14 +436,16 @@ pub struct Rustc { impl Step for Rustc { type Output = GeneratedTarball; - - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rustc") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustc { target_compiler: run.builder.compiler(run.builder.top_stage, run.target), @@ -800,12 +810,15 @@ impl Std { impl Step for Std { type Output = Option; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rust-std") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Std::new(run.builder, run.target)); } @@ -862,13 +875,16 @@ impl RustcDev { impl Step for RustcDev { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rustc-dev") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(RustcDev::new(run.builder, run.target)); } @@ -928,11 +944,12 @@ pub struct Analysis { impl Step for Analysis { type Output = Option; - const DEFAULT: bool = true; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "analysis"); - run.alias("rust-analysis").default_condition(default) + run.alias("rust-analysis") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "analysis") } fn make_run(run: RunConfig<'_>) { @@ -1100,13 +1117,16 @@ pub struct Src; impl Step for Src { /// The output path of the src installer tarball type Output = GeneratedTarball; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rust-src") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Src); } @@ -1161,12 +1181,14 @@ pub struct PlainSourceTarball; impl Step for PlainSourceTarball { /// Produces the location of the tarball generated type Output = GeneratedTarball; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.alias("rustc-src").default_condition(builder.config.rust_dist_src) + run.alias("rustc-src") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.rust_dist_src } fn make_run(run: RunConfig<'_>) { @@ -1309,12 +1331,14 @@ pub struct Cargo { impl Step for Cargo { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "cargo"); - run.alias("cargo").default_condition(default) + run.alias("cargo") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "cargo") } fn make_run(run: RunConfig<'_>) { @@ -1367,12 +1391,14 @@ pub struct RustAnalyzer { impl Step for RustAnalyzer { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "rust-analyzer"); - run.alias("rust-analyzer").default_condition(default) + run.alias("rust-analyzer") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "rust-analyzer") } fn make_run(run: RunConfig<'_>) { @@ -1410,12 +1436,14 @@ pub struct Clippy { impl Step for Clippy { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "clippy"); - run.alias("clippy").default_condition(default) + run.alias("clippy") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "clippy") } fn make_run(run: RunConfig<'_>) { @@ -1456,12 +1484,14 @@ pub struct Miri { impl Step for Miri { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "miri"); - run.alias("miri").default_condition(default) + run.alias("miri") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "miri") } fn make_run(run: RunConfig<'_>) { @@ -1504,20 +1534,21 @@ pub struct CraneliftCodegenBackend { impl Step for CraneliftCodegenBackend { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias("rustc_codegen_cranelift") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { // We only want to build the cranelift backend in `x dist` if the backend was enabled // in rust.codegen-backends. // Sadly, we don't have access to the actual target for which we're disting clif here.. // So we just use the host target. - let clif_enabled_by_default = run - .builder + builder .config - .enabled_codegen_backends(run.builder.host_target) - .contains(&CodegenBackendKind::Cranelift); - run.alias("rustc_codegen_cranelift").default_condition(clif_enabled_by_default) + .enabled_codegen_backends(builder.host_target) + .contains(&CodegenBackendKind::Cranelift) } fn make_run(run: RunConfig<'_>) { @@ -1590,12 +1621,14 @@ pub struct Rustfmt { impl Step for Rustfmt { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "rustfmt"); - run.alias("rustfmt").default_condition(default) + run.alias("rustfmt") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "rustfmt") } fn make_run(run: RunConfig<'_>) { @@ -1632,12 +1665,14 @@ pub struct Extended { impl Step for Extended { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.alias("extended").default_condition(builder.config.extended) + run.alias("extended") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.extended } fn make_run(run: RunConfig<'_>) { @@ -2379,17 +2414,18 @@ pub struct LlvmTools { impl Step for LlvmTools { type Output = Option; const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "llvm-tools"); - let mut run = run.alias("llvm-tools"); for tool in LLVM_TOOLS { run = run.alias(tool); } - run.default_condition(default) + run + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "llvm-tools") } fn make_run(run: RunConfig<'_>) { @@ -2482,12 +2518,14 @@ pub struct LlvmBitcodeLinker { impl Step for LlvmBitcodeLinker { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = should_build_extended_tool(run.builder, "llvm-bitcode-linker"); - run.alias("llvm-bitcode-linker").default_condition(default) + run.alias("llvm-bitcode-linker") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + should_build_extended_tool(builder, "llvm-bitcode-linker") } fn make_run(run: RunConfig<'_>) { @@ -2534,13 +2572,16 @@ pub struct RustDev { impl Step for RustDev { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("rust-dev") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(RustDev { target: run.target }); } @@ -2723,13 +2764,16 @@ pub struct ReproducibleArtifacts { impl Step for ReproducibleArtifacts { type Output = Option; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("reproducible-artifacts") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(ReproducibleArtifacts { target: run.target }); } diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 30e7fbb265ac4..b86582807f722 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -32,11 +32,13 @@ macro_rules! book { impl Step for $name { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path($path).default_condition(builder.config.docs) + run.path($path) + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -85,11 +87,13 @@ pub struct UnstableBook { impl Step for UnstableBook { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/doc/unstable-book").default_condition(builder.config.docs) + run.path("src/doc/unstable-book") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -213,11 +217,13 @@ pub struct TheBook { impl Step for TheBook { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/doc/book").default_condition(builder.config.docs) + run.path("src/doc/book") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -337,11 +343,13 @@ pub struct Standalone { impl Step for Standalone { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/doc").alias("standalone").default_condition(builder.config.docs) + run.path("src/doc").alias("standalone") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -447,11 +455,13 @@ pub struct Releases { impl Step for Releases { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("RELEASES.md").alias("releases").default_condition(builder.config.docs) + run.path("RELEASES.md").alias("releases") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -552,13 +562,16 @@ pub struct SharedAssets { impl Step for SharedAssets { type Output = SharedAssetsPaths; - const DEFAULT: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { // Other tasks depend on this, no need to execute it on its own run.never() } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + /// Generate shared resources used by other pieces of documentation. fn run(self, builder: &Builder<'_>) -> Self::Output { let out = builder.doc_out(self.target); @@ -631,11 +644,12 @@ impl Step for Std { /// Path to a directory with the built documentation. type Output = PathBuf; - const DEFAULT: bool = true; - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.crate_or_deps("sysroot").path("library").default_condition(builder.config.docs) + run.crate_or_deps("sysroot").path("library") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -858,14 +872,14 @@ impl Rustc { impl Step for Rustc { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.crate_or_deps("rustc-main") - .path("compiler") - .default_condition(builder.config.compiler_docs) + run.crate_or_deps("rustc-main").path("compiler") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.compiler_docs } fn make_run(run: RunConfig<'_>) { @@ -1005,12 +1019,14 @@ macro_rules! tool_doc { impl Step for $tool { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path($path).default_condition(builder.config.compiler_docs) + run.path($path) + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.compiler_docs } fn make_run(run: RunConfig<'_>) { @@ -1206,12 +1222,14 @@ pub struct ErrorIndex { impl Step for ErrorIndex { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/tools/error_index_generator").default_condition(builder.config.docs) + run.path("src/tools/error_index_generator") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -1251,12 +1269,14 @@ pub struct UnstableBookGen { impl Step for UnstableBookGen { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/tools/unstable-book-gen").default_condition(builder.config.docs) + run.path("src/tools/unstable-book-gen") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -1318,12 +1338,14 @@ impl RustcBook { impl Step for RustcBook { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/doc/rustc").default_condition(builder.config.docs) + run.path("src/doc/rustc") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { @@ -1415,11 +1437,13 @@ pub struct Reference { impl Step for Reference { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/doc/reference").default_condition(builder.config.docs) + run.path("src/doc/reference") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs } fn make_run(run: RunConfig<'_>) { diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index ce68dbf5a2010..d52cc52abbd3e 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -180,13 +180,16 @@ macro_rules! install { impl Step for $name { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = $IS_HOST; $(const $c: bool = true;)* fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let $_config = &run.builder.config; - run.$condition_name($path_or_alias).default_condition($default_cond) + run.$condition_name($path_or_alias) + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + let $_config = &builder.config; + $default_cond } fn make_run(run: RunConfig<'_>) { @@ -307,13 +310,15 @@ pub struct Src { impl Step for Src { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let config = &run.builder.config; - let cond = config.extended && config.tools.as_ref().is_none_or(|t| t.contains("src")); - run.path("src").default_condition(cond) + run.path("src") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + let config = &builder.config; + config.extended && config.tools.as_ref().is_none_or(|t| t.contains("src")) } fn make_run(run: RunConfig<'_>) { diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 5446ec085ffd0..1f6c2facc9c2a 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -445,14 +445,16 @@ pub struct CoverageDump; impl Step for CoverageDump { type Output = (); - - const DEFAULT: bool = false; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/coverage-dump") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Self {}); } diff --git a/src/bootstrap/src/core/build_steps/setup.rs b/src/bootstrap/src/core/build_steps/setup.rs index 380c774b143c6..e30d28f215963 100644 --- a/src/bootstrap/src/core/build_steps/setup.rs +++ b/src/bootstrap/src/core/build_steps/setup.rs @@ -103,7 +103,6 @@ impl fmt::Display for Profile { impl Step for Profile { type Output = (); - const DEFAULT: bool = true; fn should_run(mut run: ShouldRun<'_>) -> ShouldRun<'_> { for choice in Profile::all() { @@ -112,6 +111,10 @@ impl Step for Profile { run } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { if run.builder.config.dry_run() { return; @@ -231,12 +234,15 @@ fn setup_config_toml(path: &Path, profile: Profile, config: &Config) { pub struct Link; impl Step for Link { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("link") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { if run.builder.config.dry_run() { return; @@ -450,12 +456,15 @@ pub struct Hook; impl Step for Hook { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("hook") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { if let [cmd] = &run.paths[..] && cmd.assert_single_path().path.as_path().as_os_str() == "hook" @@ -670,12 +679,15 @@ pub struct Editor; impl Step for Editor { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("editor") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { if run.builder.config.dry_run() { return; diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index 2cc691832b5f0..964ccf1c31088 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -19,12 +19,15 @@ pub(crate) struct MirOptPanicAbortSyntheticTarget { impl Step for MirOptPanicAbortSyntheticTarget { type Output = TargetSelection; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn run(self, builder: &Builder<'_>) -> Self::Output { create_synthetic_target(builder, self.compiler, "miropt-abort", self.base, |spec| { spec.insert("panic-strategy".into(), "abort".into()); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 2332256c1fbd3..2f2ee890e5014 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -49,7 +49,6 @@ pub struct CrateBootstrap { impl Step for CrateBootstrap { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { // This step is responsible for several different tool paths. @@ -64,6 +63,10 @@ impl Step for CrateBootstrap { .alias("tidyselftest") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { // Create and ensure a separate instance of this step for each path // that was selected on the command-line (or selected by default). @@ -114,7 +117,18 @@ pub struct Linkcheck { impl Step for Linkcheck { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/linkchecker") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.docs + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Linkcheck { host: run.target }); + } /// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler. /// @@ -170,23 +184,19 @@ You can skip linkcheck with --skip src/tools/linkchecker" linkchecker.delay_failure().arg(builder.out.join(host).join("doc")).run(builder); } - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - let run = run.path("src/tools/linkchecker"); - run.default_condition(builder.config.docs) - } - - fn make_run(run: RunConfig<'_>) { - run.builder.ensure(Linkcheck { host: run.target }); - } - fn metadata(&self) -> Option { Some(StepMetadata::test("link-check", self.host)) } } fn check_if_tidy_is_installed(builder: &Builder<'_>) -> bool { - command("tidy").allow_failure().arg("--version").run_capture_stdout(builder).is_success() + command("tidy") + .allow_failure() + .arg("--version") + // Cache the output to avoid running this command more than once (per builder). + .cached() + .run_capture_stdout(builder) + .is_success() } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -196,13 +206,14 @@ pub struct HtmlCheck { impl Step for HtmlCheck { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - let run = run.path("src/tools/html-checker"); - run.lazy_default_condition(Box::new(|| check_if_tidy_is_installed(builder))) + run.path("src/tools/html-checker") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + check_if_tidy_is_installed(builder) } fn make_run(run: RunConfig<'_>) { @@ -427,12 +438,15 @@ pub struct RustAnalyzer { impl Step for RustAnalyzer { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rust-analyzer") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Self { compilers: RustcPrivateCompilers::new( @@ -829,12 +843,15 @@ pub struct Clippy { impl Step for Clippy { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = false; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.suite_path("src/tools/clippy/tests").path("src/tools/clippy") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Clippy { compilers: RustcPrivateCompilers::new( @@ -936,13 +953,16 @@ pub struct RustdocTheme { impl Step for RustdocTheme { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rustdoc-themes") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let test_compiler = run.builder.compiler(run.builder.top_stage, run.target); @@ -986,12 +1006,14 @@ pub struct RustdocJSStd { impl Step for RustdocJSStd { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = run.builder.config.nodejs.is_some(); - run.suite_path("tests/rustdoc-js-std").default_condition(default) + run.suite_path("tests/rustdoc-js-std") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.nodejs.is_some() } fn make_run(run: RunConfig<'_>) { @@ -1047,12 +1069,14 @@ pub struct RustdocJSNotStd { impl Step for RustdocJSNotStd { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = run.builder.config.nodejs.is_some(); - run.suite_path("tests/rustdoc-js").default_condition(default) + run.suite_path("tests/rustdoc-js") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.nodejs.is_some() } fn make_run(run: RunConfig<'_>) { @@ -1088,14 +1112,17 @@ fn get_browser_ui_test_version_inner( if global { command.arg("--global"); } - let lines = command.allow_failure().run_capture(builder).stdout(); + // Cache the command output so that `test::RustdocGUI` only performs these + // command-line probes once. + let lines = command.allow_failure().cached().run_capture(builder).stdout(); lines .lines() .find_map(|l| l.split(':').nth(1)?.strip_prefix("browser-ui-test@")) .map(|v| v.to_owned()) } -fn get_browser_ui_test_version(builder: &Builder<'_>, yarn: &Path) -> Option { +fn get_browser_ui_test_version(builder: &Builder<'_>) -> Option { + let yarn = builder.config.yarn.as_deref()?; get_browser_ui_test_version_inner(builder, yarn, false) .or_else(|| get_browser_ui_test_version_inner(builder, yarn, true)) } @@ -1110,22 +1137,16 @@ pub struct RustdocGUI { impl Step for RustdocGUI { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - let run = run.suite_path("tests/rustdoc-gui"); - run.lazy_default_condition(Box::new(move || { - builder.config.nodejs.is_some() - && builder.doc_tests != DocTests::Only - && builder - .config - .yarn - .as_ref() - .map(|p| get_browser_ui_test_version(builder, p).is_some()) - .unwrap_or(false) - })) + run.suite_path("tests/rustdoc-gui") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.config.nodejs.is_some() + && builder.doc_tests != DocTests::Only + && get_browser_ui_test_version(builder).is_some() } fn make_run(run: RunConfig<'_>) { @@ -1207,9 +1228,20 @@ pub struct Tidy; impl Step for Tidy { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/tidy") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.doc_tests != DocTests::Only + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Tidy); + } + /// Runs the `tidy` tool. /// /// This tool in `src/tools` checks up on various bits and pieces of style and @@ -1316,15 +1348,6 @@ HELP: to skip test's attempt to check tidiness, pass `--skip src/tools/tidy` to } } - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let default = run.builder.doc_tests != DocTests::Only; - run.path("src/tools/tidy").default_condition(default) - } - - fn make_run(run: RunConfig<'_>) { - run.builder.ensure(Tidy); - } - fn metadata(&self) -> Option { Some(StepMetadata::test("tidy", TargetSelection::default())) } @@ -1433,7 +1456,6 @@ macro_rules! test { impl Step for $name { type Output = (); - const DEFAULT: bool = $default; const IS_HOST: bool = (const { #[allow(unused_assignments, unused_mut)] let mut value = false; @@ -1445,6 +1467,10 @@ macro_rules! test { run.suite_path($path) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + const { $default } + } + fn make_run(run: RunConfig<'_>) { let test_compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); @@ -1574,7 +1600,6 @@ impl Coverage { impl Step for Coverage { type Output = (); - const DEFAULT: bool = true; /// Compiletest will automatically skip the "coverage-run" tests if necessary. const IS_HOST: bool = false; @@ -1591,6 +1616,10 @@ impl Step for Coverage { run } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); let target = run.target; @@ -1667,12 +1696,15 @@ pub struct MirOpt { impl Step for MirOpt { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.suite_path("tests/mir-opt") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let compiler = run.builder.compiler(run.builder.top_stage, run.build_triple()); run.builder.ensure(MirOpt { compiler, target: run.target }); @@ -2584,13 +2616,16 @@ macro_rules! test_book { impl Step for $name { type Output = (); - const DEFAULT: bool = $default; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path($path) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + const { $default } + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure($name { test_compiler: run.builder.compiler(run.builder.top_stage, run.target), @@ -2644,7 +2679,6 @@ pub struct ErrorIndex { impl Step for ErrorIndex { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { @@ -2653,6 +2687,10 @@ impl Step for ErrorIndex { run.path("src/tools/error_index_generator").alias("error-index") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { // error_index_generator depends on librustdoc. Use the compiler that // is normally used to build rustdoc for other tests (like compiletest @@ -2735,13 +2773,16 @@ pub struct CrateLibrustc { impl Step for CrateLibrustc { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.crate_or_deps("rustc-main").path("compiler") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let host = run.build_triple(); @@ -2890,12 +2931,15 @@ pub struct Crate { impl Step for Crate { type Output = (); - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.crate_or_deps("sysroot").crate_or_deps("coretests").crate_or_deps("alloctests") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let host = run.build_triple(); @@ -3023,13 +3067,16 @@ pub struct CrateRustdoc { impl Step for CrateRustdoc { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.paths(&["src/librustdoc", "src/tools/rustdoc"]) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; @@ -3116,13 +3163,16 @@ pub struct CrateRustdocJsonTypes { impl Step for CrateRustdocJsonTypes { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/rustdoc-json-types") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; @@ -3351,15 +3401,17 @@ pub(crate) struct BootstrapPy; impl Step for BootstrapPy { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias("bootstrap-py") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { // Bootstrap tests might not be perfectly self-contained and can depend // on the environment, so only run them by default in CI, not locally. // See `test::Bootstrap::should_run`. - let is_ci = run.builder.config.is_running_on_ci; - run.alias("bootstrap-py").default_condition(is_ci) + builder.config.is_running_on_ci } fn make_run(run: RunConfig<'_>) { @@ -3388,9 +3440,19 @@ pub struct Bootstrap; impl Step for Bootstrap { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/bootstrap") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + // Bootstrap tests might not be perfectly self-contained and can depend on the external + // environment, submodules that are checked out, etc. + // Therefore we only run them by default on CI. + builder.config.is_running_on_ci + } + /// Tests the build system itself. fn run(self, builder: &Builder<'_>) { let host = builder.config.host_target; @@ -3429,14 +3491,6 @@ impl Step for Bootstrap { run_cargo_test(cargo, &[], &[], None, host, builder); } - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - // Bootstrap tests might not be perfectly self-contained and can depend on the external - // environment, submodules that are checked out, etc. - // Therefore we only run them by default on CI. - let runs_on_ci = run.builder.config.is_running_on_ci; - run.path("src/bootstrap").default_condition(runs_on_ci) - } - fn make_run(run: RunConfig<'_>) { run.builder.ensure(Bootstrap); } @@ -3455,13 +3509,16 @@ pub struct TierCheck { impl Step for TierCheck { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/tier-check") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder .ensure(TierCheck { test_compiler: get_compiler_to_test(run.builder, run.target) }); @@ -3504,14 +3561,16 @@ pub struct LintDocs { impl Step for LintDocs { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let stage = run.builder.top_stage; + run.path("src/tools/lint-docs") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { // Lint docs tests might not work with stage 1, so do not run this test by default in // `x test` below stage 2. - run.path("src/tools/lint-docs").default_condition(stage > 1) + builder.top_stage >= 2 } fn make_run(run: RunConfig<'_>) { @@ -3549,7 +3608,18 @@ pub struct RustInstaller; impl Step for RustInstaller { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/rust-installer") + } + + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(Self); + } /// Ensure the version placeholder replacement tool builds fn run(self, builder: &Builder<'_>) { @@ -3587,14 +3657,6 @@ impl Step for RustInstaller { cmd.env("TMP_DIR", &tmpdir); cmd.delay_failure().run(builder); } - - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.path("src/tools/rust-installer") - } - - fn make_run(run: RunConfig<'_>) { - run.builder.ensure(Self); - } } #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -3666,13 +3728,16 @@ pub struct CodegenCranelift { impl Step for CodegenCranelift { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.paths(&["compiler/rustc_codegen_cranelift"]) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let host = run.build_triple(); @@ -3784,13 +3849,16 @@ pub struct CodegenGCC { impl Step for CodegenGCC { type Output = (); - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.paths(&["compiler/rustc_codegen_gcc"]) } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { let builder = run.builder; let host = run.build_triple(); @@ -3912,12 +3980,15 @@ pub struct TestFloatParse { impl Step for TestFloatParse { type Output = (); const IS_HOST: bool = true; - const DEFAULT: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/test-float-parse") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Self { build_compiler: get_compiler_to_test(run.builder, run.target), diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 0d765018d77bf..db84d7b5c661b 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -681,13 +681,16 @@ impl Step for Rustdoc { /// Path to the built rustdoc binary. type Output = PathBuf; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.path("src/tools/rustdoc").path("src/librustdoc") } + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + fn make_run(run: RunConfig<'_>) { run.builder.ensure(Rustdoc { target_compiler: run.builder.compiler(run.builder.top_stage, run.target), @@ -803,12 +806,14 @@ impl Cargo { impl Step for Cargo { type Output = ToolBuildResult; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/tools/cargo").default_condition(builder.tool_enabled("cargo")) + run.path("src/tools/cargo") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.tool_enabled("cargo") } fn make_run(run: RunConfig<'_>) { @@ -1025,12 +1030,14 @@ impl RustAnalyzer { impl Step for RustAnalyzer { type Output = ToolBuildResult; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; - run.path("src/tools/rust-analyzer").default_condition(builder.tool_enabled("rust-analyzer")) + run.path("src/tools/rust-analyzer") + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.tool_enabled("rust-analyzer") } fn make_run(run: RunConfig<'_>) { @@ -1077,19 +1084,17 @@ impl RustAnalyzerProcMacroSrv { impl Step for RustAnalyzerProcMacroSrv { type Output = ToolBuildResult; - - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; // Allow building `rust-analyzer-proc-macro-srv` both as part of the `rust-analyzer` and as a stand-alone tool. run.path("src/tools/rust-analyzer") .path("src/tools/rust-analyzer/crates/proc-macro-srv-cli") - .default_condition( - builder.tool_enabled("rust-analyzer") - || builder.tool_enabled("rust-analyzer-proc-macro-srv"), - ) + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.tool_enabled("rust-analyzer") + || builder.tool_enabled("rust-analyzer-proc-macro-srv") } fn make_run(run: RunConfig<'_>) { @@ -1168,13 +1173,14 @@ impl LlvmBitcodeLinker { impl Step for LlvmBitcodeLinker { type Output = ToolBuildResult; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - let builder = run.builder; run.path("src/tools/llvm-bitcode-linker") - .default_condition(builder.tool_enabled("llvm-bitcode-linker")) + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + builder.tool_enabled("llvm-bitcode-linker") } fn make_run(run: RunConfig<'_>) { @@ -1218,13 +1224,16 @@ pub enum LibcxxVersion { impl Step for LibcxxVersionTool { type Output = LibcxxVersion; - const DEFAULT: bool = false; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.never() } + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + fn run(self, builder: &Builder<'_>) -> LibcxxVersion { let out_dir = builder.out.join(self.target.to_string()).join("libcxx-version"); let executable = out_dir.join(exe("libcxx-version", self.target)); @@ -1425,14 +1434,19 @@ macro_rules! tool_rustc_extended { impl Step for $name { type Output = ToolBuildResult; - const DEFAULT: bool = true; // Overridden by `should_run_tool_build_step` const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { should_run_extended_rustc_tool( run, - $tool_name, $path, + ) + } + + fn is_default_step(builder: &Builder<'_>) -> bool { + extended_rustc_tool_is_default_step( + builder, + $tool_name, $stable, ) } @@ -1466,28 +1480,28 @@ macro_rules! tool_rustc_extended { } } -fn should_run_extended_rustc_tool<'a>( - run: ShouldRun<'a>, +fn should_run_extended_rustc_tool<'a>(run: ShouldRun<'a>, path: &'static str) -> ShouldRun<'a> { + run.path(path) +} + +fn extended_rustc_tool_is_default_step( + builder: &Builder<'_>, tool_name: &'static str, - path: &'static str, stable: bool, -) -> ShouldRun<'a> { - let builder = run.builder; - run.path(path).default_condition( - builder.config.extended - && builder.config.tools.as_ref().map_or( - // By default, on nightly/dev enable all tools, else only - // build stable tools. - stable || builder.build.unstable_features(), - // If `tools` is set, search list for this tool. - |tools| { - tools.iter().any(|tool| match tool.as_ref() { - "clippy" => tool_name == "clippy-driver", - x => tool_name == x, - }) - }, - ), - ) +) -> bool { + builder.config.extended + && builder.config.tools.as_ref().map_or( + // By default, on nightly/dev enable all tools, else only + // build stable tools. + stable || builder.build.unstable_features(), + // If `tools` is set, search list for this tool. + |tools| { + tools.iter().any(|tool| match tool.as_ref() { + "clippy" => tool_name == "clippy-driver", + x => tool_name == x, + }) + }, + ) } fn build_extended_rustc_tool( diff --git a/src/bootstrap/src/core/build_steps/vendor.rs b/src/bootstrap/src/core/build_steps/vendor.rs index 72250a26f376e..36a740c6f35fc 100644 --- a/src/bootstrap/src/core/build_steps/vendor.rs +++ b/src/bootstrap/src/core/build_steps/vendor.rs @@ -53,11 +53,14 @@ pub(crate) struct Vendor { impl Step for Vendor { type Output = VendorOutput; - const DEFAULT: bool = true; const IS_HOST: bool = true; fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { - run.alias("placeholder").default_condition(true) + run.alias("placeholder") + } + + fn is_default_step(_builder: &Builder<'_>) -> bool { + true } fn make_run(run: RunConfig<'_>) { diff --git a/src/bootstrap/src/core/builder/cli_paths.rs b/src/bootstrap/src/core/builder/cli_paths.rs index fef1979465e8b..470e83d341c7a 100644 --- a/src/bootstrap/src/core/builder/cli_paths.rs +++ b/src/bootstrap/src/core/builder/cli_paths.rs @@ -136,7 +136,7 @@ pub(crate) fn match_paths_to_steps_and_run( if paths.is_empty() || builder.config.include_default_paths { for StepExtra { desc, should_run } in &steps { - if desc.default && should_run.is_really_default() { + if (desc.is_default_step_fn)(builder) { desc.maybe_run(builder, should_run.paths.iter().cloned().collect()); } } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap new file mode 100644 index 0000000000000..8a7815487913e --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_bench.snap @@ -0,0 +1,101 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: bench +--- +[Bench] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({bench::library/alloc}) + - Set({bench::library/alloctests}) + - Set({bench::library/compiler-builtins/compiler-builtins}) + - Set({bench::library/core}) + - Set({bench::library/coretests}) + - Set({bench::library/panic_abort}) + - Set({bench::library/panic_unwind}) + - Set({bench::library/proc_macro}) + - Set({bench::library/rustc-std-workspace-core}) + - Set({bench::library/std}) + - Set({bench::library/std_detect}) + - Set({bench::library/sysroot}) + - Set({bench::library/test}) + - Set({bench::library/unwind}) +[Bench] test::CrateLibrustc + targets: [x86_64-unknown-linux-gnu] + - Set({bench::compiler}) + - Set({bench::compiler/rustc}) + - Set({bench::compiler/rustc_abi}) + - Set({bench::compiler/rustc_arena}) + - Set({bench::compiler/rustc_ast}) + - Set({bench::compiler/rustc_ast_ir}) + - Set({bench::compiler/rustc_ast_lowering}) + - Set({bench::compiler/rustc_ast_passes}) + - Set({bench::compiler/rustc_ast_pretty}) + - Set({bench::compiler/rustc_attr_parsing}) + - Set({bench::compiler/rustc_baked_icu_data}) + - Set({bench::compiler/rustc_borrowck}) + - Set({bench::compiler/rustc_builtin_macros}) + - Set({bench::compiler/rustc_codegen_llvm}) + - Set({bench::compiler/rustc_codegen_ssa}) + - Set({bench::compiler/rustc_const_eval}) + - Set({bench::compiler/rustc_data_structures}) + - Set({bench::compiler/rustc_driver}) + - Set({bench::compiler/rustc_driver_impl}) + - Set({bench::compiler/rustc_error_codes}) + - Set({bench::compiler/rustc_error_messages}) + - Set({bench::compiler/rustc_errors}) + - Set({bench::compiler/rustc_expand}) + - Set({bench::compiler/rustc_feature}) + - Set({bench::compiler/rustc_fluent_macro}) + - Set({bench::compiler/rustc_fs_util}) + - Set({bench::compiler/rustc_graphviz}) + - Set({bench::compiler/rustc_hashes}) + - Set({bench::compiler/rustc_hir}) + - Set({bench::compiler/rustc_hir_analysis}) + - Set({bench::compiler/rustc_hir_id}) + - Set({bench::compiler/rustc_hir_pretty}) + - Set({bench::compiler/rustc_hir_typeck}) + - Set({bench::compiler/rustc_incremental}) + - Set({bench::compiler/rustc_index}) + - Set({bench::compiler/rustc_index_macros}) + - Set({bench::compiler/rustc_infer}) + - Set({bench::compiler/rustc_interface}) + - Set({bench::compiler/rustc_lexer}) + - Set({bench::compiler/rustc_lint}) + - Set({bench::compiler/rustc_lint_defs}) + - Set({bench::compiler/rustc_llvm}) + - Set({bench::compiler/rustc_log}) + - Set({bench::compiler/rustc_macros}) + - Set({bench::compiler/rustc_metadata}) + - Set({bench::compiler/rustc_middle}) + - Set({bench::compiler/rustc_mir_build}) + - Set({bench::compiler/rustc_mir_dataflow}) + - Set({bench::compiler/rustc_mir_transform}) + - Set({bench::compiler/rustc_monomorphize}) + - Set({bench::compiler/rustc_next_trait_solver}) + - Set({bench::compiler/rustc_parse}) + - Set({bench::compiler/rustc_parse_format}) + - Set({bench::compiler/rustc_passes}) + - Set({bench::compiler/rustc_pattern_analysis}) + - Set({bench::compiler/rustc_privacy}) + - Set({bench::compiler/rustc_proc_macro}) + - Set({bench::compiler/rustc_public}) + - Set({bench::compiler/rustc_public_bridge}) + - Set({bench::compiler/rustc_query_impl}) + - Set({bench::compiler/rustc_query_system}) + - Set({bench::compiler/rustc_resolve}) + - Set({bench::compiler/rustc_sanitizers}) + - Set({bench::compiler/rustc_serialize}) + - Set({bench::compiler/rustc_session}) + - Set({bench::compiler/rustc_span}) + - Set({bench::compiler/rustc_symbol_mangling}) + - Set({bench::compiler/rustc_target}) + - Set({bench::compiler/rustc_thread_pool}) + - Set({bench::compiler/rustc_trait_selection}) + - Set({bench::compiler/rustc_traits}) + - Set({bench::compiler/rustc_transmute}) + - Set({bench::compiler/rustc_ty_utils}) + - Set({bench::compiler/rustc_type_ir}) + - Set({bench::compiler/rustc_type_ir_macros}) + - Set({bench::compiler/rustc_windows_rc}) +[Bench] test::CrateRustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({bench::src/librustdoc, bench::src/tools/rustdoc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap new file mode 100644 index 0000000000000..71f12ecd501a7 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clean.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: clean +--- +[Clean] clean::CleanAll + targets: [aarch64-unknown-linux-gnu] + - Set({}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap new file mode 100644 index 0000000000000..fe83346412857 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_clippy.snap @@ -0,0 +1,97 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: clippy +--- +[Clippy] clippy::Std + targets: [aarch64-unknown-linux-gnu] + - Set({clippy::library}) + - Set({clippy::library/alloc}) + - Set({clippy::library/compiler-builtins/compiler-builtins}) + - Set({clippy::library/core}) + - Set({clippy::library/panic_abort}) + - Set({clippy::library/panic_unwind}) + - Set({clippy::library/proc_macro}) + - Set({clippy::library/rustc-std-workspace-core}) + - Set({clippy::library/std}) + - Set({clippy::library/std_detect}) + - Set({clippy::library/sysroot}) + - Set({clippy::library/test}) + - Set({clippy::library/unwind}) +[Clippy] clippy::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({clippy::compiler}) + - Set({clippy::compiler/rustc}) + - Set({clippy::compiler/rustc_abi}) + - Set({clippy::compiler/rustc_arena}) + - Set({clippy::compiler/rustc_ast}) + - Set({clippy::compiler/rustc_ast_ir}) + - Set({clippy::compiler/rustc_ast_lowering}) + - Set({clippy::compiler/rustc_ast_passes}) + - Set({clippy::compiler/rustc_ast_pretty}) + - Set({clippy::compiler/rustc_attr_parsing}) + - Set({clippy::compiler/rustc_baked_icu_data}) + - Set({clippy::compiler/rustc_borrowck}) + - Set({clippy::compiler/rustc_builtin_macros}) + - Set({clippy::compiler/rustc_codegen_llvm}) + - Set({clippy::compiler/rustc_codegen_ssa}) + - Set({clippy::compiler/rustc_const_eval}) + - Set({clippy::compiler/rustc_data_structures}) + - Set({clippy::compiler/rustc_driver}) + - Set({clippy::compiler/rustc_driver_impl}) + - Set({clippy::compiler/rustc_error_codes}) + - Set({clippy::compiler/rustc_error_messages}) + - Set({clippy::compiler/rustc_errors}) + - Set({clippy::compiler/rustc_expand}) + - Set({clippy::compiler/rustc_feature}) + - Set({clippy::compiler/rustc_fluent_macro}) + - Set({clippy::compiler/rustc_fs_util}) + - Set({clippy::compiler/rustc_graphviz}) + - Set({clippy::compiler/rustc_hashes}) + - Set({clippy::compiler/rustc_hir}) + - Set({clippy::compiler/rustc_hir_analysis}) + - Set({clippy::compiler/rustc_hir_id}) + - Set({clippy::compiler/rustc_hir_pretty}) + - Set({clippy::compiler/rustc_hir_typeck}) + - Set({clippy::compiler/rustc_incremental}) + - Set({clippy::compiler/rustc_index}) + - Set({clippy::compiler/rustc_index_macros}) + - Set({clippy::compiler/rustc_infer}) + - Set({clippy::compiler/rustc_interface}) + - Set({clippy::compiler/rustc_lexer}) + - Set({clippy::compiler/rustc_lint}) + - Set({clippy::compiler/rustc_lint_defs}) + - Set({clippy::compiler/rustc_llvm}) + - Set({clippy::compiler/rustc_log}) + - Set({clippy::compiler/rustc_macros}) + - Set({clippy::compiler/rustc_metadata}) + - Set({clippy::compiler/rustc_middle}) + - Set({clippy::compiler/rustc_mir_build}) + - Set({clippy::compiler/rustc_mir_dataflow}) + - Set({clippy::compiler/rustc_mir_transform}) + - Set({clippy::compiler/rustc_monomorphize}) + - Set({clippy::compiler/rustc_next_trait_solver}) + - Set({clippy::compiler/rustc_parse}) + - Set({clippy::compiler/rustc_parse_format}) + - Set({clippy::compiler/rustc_passes}) + - Set({clippy::compiler/rustc_pattern_analysis}) + - Set({clippy::compiler/rustc_privacy}) + - Set({clippy::compiler/rustc_proc_macro}) + - Set({clippy::compiler/rustc_public}) + - Set({clippy::compiler/rustc_public_bridge}) + - Set({clippy::compiler/rustc_query_impl}) + - Set({clippy::compiler/rustc_query_system}) + - Set({clippy::compiler/rustc_resolve}) + - Set({clippy::compiler/rustc_sanitizers}) + - Set({clippy::compiler/rustc_serialize}) + - Set({clippy::compiler/rustc_session}) + - Set({clippy::compiler/rustc_span}) + - Set({clippy::compiler/rustc_symbol_mangling}) + - Set({clippy::compiler/rustc_target}) + - Set({clippy::compiler/rustc_thread_pool}) + - Set({clippy::compiler/rustc_trait_selection}) + - Set({clippy::compiler/rustc_traits}) + - Set({clippy::compiler/rustc_transmute}) + - Set({clippy::compiler/rustc_ty_utils}) + - Set({clippy::compiler/rustc_type_ir}) + - Set({clippy::compiler/rustc_type_ir_macros}) + - Set({clippy::compiler/rustc_windows_rc}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_doc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_doc.snap new file mode 100644 index 0000000000000..610a71ab70cf3 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_doc.snap @@ -0,0 +1,69 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: doc +--- +[Doc] doc::UnstableBook + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/unstable-book}) +[Doc] doc::UnstableBookGen + targets: [x86_64-unknown-linux-gnu] + - Set({doc::src/tools/unstable-book-gen}) +[Doc] doc::TheBook + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/book}) +[Doc] doc::Standalone + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc}) + - Set({doc::standalone}) +[Doc] doc::Std + targets: [aarch64-unknown-linux-gnu] + - Set({doc::library}) + - Set({doc::library/alloc}) + - Set({doc::library/compiler-builtins/compiler-builtins}) + - Set({doc::library/core}) + - Set({doc::library/panic_abort}) + - Set({doc::library/panic_unwind}) + - Set({doc::library/proc_macro}) + - Set({doc::library/rustc-std-workspace-core}) + - Set({doc::library/std}) + - Set({doc::library/std_detect}) + - Set({doc::library/sysroot}) + - Set({doc::library/test}) + - Set({doc::library/unwind}) +[Doc] doc::ErrorIndex + targets: [x86_64-unknown-linux-gnu] + - Set({doc::src/tools/error_index_generator}) +[Doc] doc::Nomicon + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/nomicon}) +[Doc] doc::Reference + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/reference}) +[Doc] doc::RustdocBook + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/rustdoc}) +[Doc] doc::RustByExample + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/rust-by-example}) +[Doc] doc::RustcBook + targets: [x86_64-unknown-linux-gnu] + - Set({doc::src/doc/rustc}) +[Doc] doc::CargoBook + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/tools/cargo/src/doc}) +[Doc] doc::ClippyBook + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/tools/clippy/book}) +[Doc] doc::EmbeddedBook + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/embedded-book}) +[Doc] doc::EditionGuide + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/edition-guide}) +[Doc] doc::StyleGuide + targets: [aarch64-unknown-linux-gnu] + - Set({doc::src/doc/style-guide}) +[Doc] doc::Releases + targets: [aarch64-unknown-linux-gnu] + - Set({doc::RELEASES.md}) + - Set({doc::releases}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap new file mode 100644 index 0000000000000..222c0ffb40503 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fix.snap @@ -0,0 +1,134 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: fix +--- +[Fix] check::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({fix::compiler}) + - Set({fix::compiler/rustc}) + - Set({fix::compiler/rustc_abi}) + - Set({fix::compiler/rustc_arena}) + - Set({fix::compiler/rustc_ast}) + - Set({fix::compiler/rustc_ast_ir}) + - Set({fix::compiler/rustc_ast_lowering}) + - Set({fix::compiler/rustc_ast_passes}) + - Set({fix::compiler/rustc_ast_pretty}) + - Set({fix::compiler/rustc_attr_parsing}) + - Set({fix::compiler/rustc_baked_icu_data}) + - Set({fix::compiler/rustc_borrowck}) + - Set({fix::compiler/rustc_builtin_macros}) + - Set({fix::compiler/rustc_codegen_llvm}) + - Set({fix::compiler/rustc_codegen_ssa}) + - Set({fix::compiler/rustc_const_eval}) + - Set({fix::compiler/rustc_data_structures}) + - Set({fix::compiler/rustc_driver}) + - Set({fix::compiler/rustc_driver_impl}) + - Set({fix::compiler/rustc_error_codes}) + - Set({fix::compiler/rustc_error_messages}) + - Set({fix::compiler/rustc_errors}) + - Set({fix::compiler/rustc_expand}) + - Set({fix::compiler/rustc_feature}) + - Set({fix::compiler/rustc_fluent_macro}) + - Set({fix::compiler/rustc_fs_util}) + - Set({fix::compiler/rustc_graphviz}) + - Set({fix::compiler/rustc_hashes}) + - Set({fix::compiler/rustc_hir}) + - Set({fix::compiler/rustc_hir_analysis}) + - Set({fix::compiler/rustc_hir_id}) + - Set({fix::compiler/rustc_hir_pretty}) + - Set({fix::compiler/rustc_hir_typeck}) + - Set({fix::compiler/rustc_incremental}) + - Set({fix::compiler/rustc_index}) + - Set({fix::compiler/rustc_index_macros}) + - Set({fix::compiler/rustc_infer}) + - Set({fix::compiler/rustc_interface}) + - Set({fix::compiler/rustc_lexer}) + - Set({fix::compiler/rustc_lint}) + - Set({fix::compiler/rustc_lint_defs}) + - Set({fix::compiler/rustc_llvm}) + - Set({fix::compiler/rustc_log}) + - Set({fix::compiler/rustc_macros}) + - Set({fix::compiler/rustc_metadata}) + - Set({fix::compiler/rustc_middle}) + - Set({fix::compiler/rustc_mir_build}) + - Set({fix::compiler/rustc_mir_dataflow}) + - Set({fix::compiler/rustc_mir_transform}) + - Set({fix::compiler/rustc_monomorphize}) + - Set({fix::compiler/rustc_next_trait_solver}) + - Set({fix::compiler/rustc_parse}) + - Set({fix::compiler/rustc_parse_format}) + - Set({fix::compiler/rustc_passes}) + - Set({fix::compiler/rustc_pattern_analysis}) + - Set({fix::compiler/rustc_privacy}) + - Set({fix::compiler/rustc_proc_macro}) + - Set({fix::compiler/rustc_public}) + - Set({fix::compiler/rustc_public_bridge}) + - Set({fix::compiler/rustc_query_impl}) + - Set({fix::compiler/rustc_query_system}) + - Set({fix::compiler/rustc_resolve}) + - Set({fix::compiler/rustc_sanitizers}) + - Set({fix::compiler/rustc_serialize}) + - Set({fix::compiler/rustc_session}) + - Set({fix::compiler/rustc_span}) + - Set({fix::compiler/rustc_symbol_mangling}) + - Set({fix::compiler/rustc_target}) + - Set({fix::compiler/rustc_thread_pool}) + - Set({fix::compiler/rustc_trait_selection}) + - Set({fix::compiler/rustc_traits}) + - Set({fix::compiler/rustc_transmute}) + - Set({fix::compiler/rustc_ty_utils}) + - Set({fix::compiler/rustc_type_ir}) + - Set({fix::compiler/rustc_type_ir_macros}) + - Set({fix::compiler/rustc_windows_rc}) +[Fix] check::Rustdoc + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/librustdoc, fix::src/tools/rustdoc}) +[Fix] check::CraneliftCodegenBackend + targets: [x86_64-unknown-linux-gnu] + - Set({fix::cg_clif}) + - Set({fix::rustc_codegen_cranelift}) +[Fix] check::GccCodegenBackend + targets: [x86_64-unknown-linux-gnu] + - Set({fix::cg_gcc}) + - Set({fix::rustc_codegen_gcc}) +[Fix] check::Clippy + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/clippy}) +[Fix] check::Miri + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/miri}) +[Fix] check::CargoMiri + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/miri/cargo-miri}) +[Fix] check::MiroptTestTools + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/miropt-test-tools}) +[Fix] check::Rustfmt + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/rustfmt}) +[Fix] check::RustAnalyzer + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/rust-analyzer}) +[Fix] check::TestFloatParse + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/test-float-parse}) +[Fix] check::FeaturesStatusDump + targets: [x86_64-unknown-linux-gnu] + - Set({fix::src/tools/features-status-dump}) +[Fix] check::Std + targets: [aarch64-unknown-linux-gnu] + - Set({fix::library}) + - Set({fix::library/alloc}) + - Set({fix::library/alloctests}) + - Set({fix::library/compiler-builtins/compiler-builtins}) + - Set({fix::library/core}) + - Set({fix::library/coretests}) + - Set({fix::library/panic_abort}) + - Set({fix::library/panic_unwind}) + - Set({fix::library/proc_macro}) + - Set({fix::library/rustc-std-workspace-core}) + - Set({fix::library/std}) + - Set({fix::library/std_detect}) + - Set({fix::library/sysroot}) + - Set({fix::library/test}) + - Set({fix::library/unwind}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fmt.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fmt.snap new file mode 100644 index 0000000000000..d7a99d45bfa70 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_fmt.snap @@ -0,0 +1,5 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: fmt +--- + diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_install.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_install.snap new file mode 100644 index 0000000000000..3aca9bc2c9eef --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_install.snap @@ -0,0 +1,16 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: install +--- +[Install] install::Docs + targets: [aarch64-unknown-linux-gnu] + - Set({install::src/doc}) +[Install] install::Std + targets: [aarch64-unknown-linux-gnu] + - Set({install::library/std}) +[Install] install::Rustc + targets: [x86_64-unknown-linux-gnu] + - Set({install::compiler/rustc}) +[Install] install::LlvmTools + targets: [x86_64-unknown-linux-gnu] + - Set({install::llvm-tools}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_miri.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_miri.snap new file mode 100644 index 0000000000000..552697b378bcc --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_miri.snap @@ -0,0 +1,20 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: miri +--- +[Miri] test::Crate + targets: [aarch64-unknown-linux-gnu] + - Set({miri::library/alloc}) + - Set({miri::library/alloctests}) + - Set({miri::library/compiler-builtins/compiler-builtins}) + - Set({miri::library/core}) + - Set({miri::library/coretests}) + - Set({miri::library/panic_abort}) + - Set({miri::library/panic_unwind}) + - Set({miri::library/proc_macro}) + - Set({miri::library/rustc-std-workspace-core}) + - Set({miri::library/std}) + - Set({miri::library/std_detect}) + - Set({miri::library/sysroot}) + - Set({miri::library/test}) + - Set({miri::library/unwind}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_run.snap new file mode 100644 index 0000000000000..fb4968b51c147 --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_run.snap @@ -0,0 +1,5 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: run +--- + diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_setup.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_setup.snap new file mode 100644 index 0000000000000..e0b93e1fe7a1d --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_setup.snap @@ -0,0 +1,20 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: setup +--- +[Setup] setup::Profile + targets: [aarch64-unknown-linux-gnu] + - Set({setup::compiler}) + - Set({setup::dist}) + - Set({setup::library}) + - Set({setup::none}) + - Set({setup::tools}) +[Setup] setup::Hook + targets: [aarch64-unknown-linux-gnu] + - Set({setup::hook}) +[Setup] setup::Link + targets: [aarch64-unknown-linux-gnu] + - Set({setup::link}) +[Setup] setup::Editor + targets: [aarch64-unknown-linux-gnu] + - Set({setup::editor}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_vendor.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_vendor.snap new file mode 100644 index 0000000000000..57bfe51c2b8fa --- /dev/null +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_vendor.snap @@ -0,0 +1,7 @@ +--- +source: src/bootstrap/src/core/builder/cli_paths/tests.rs +expression: vendor +--- +[Vendor] vendor::Vendor + targets: [x86_64-unknown-linux-gnu] + - Set({vendor::placeholder}) diff --git a/src/bootstrap/src/core/builder/cli_paths/tests.rs b/src/bootstrap/src/core/builder/cli_paths/tests.rs index 7115d400c8444..49f75c8bea776 100644 --- a/src/bootstrap/src/core/builder/cli_paths/tests.rs +++ b/src/bootstrap/src/core/builder/cli_paths/tests.rs @@ -131,6 +131,7 @@ macro_rules! declare_tests { // then any fix will necessarily have to re-bless the affected tests! declare_tests!( // tidy-alphabetical-start + (x_bench, "bench"), (x_build, "build"), (x_build_compiler, "build compiler"), (x_build_compiletest, "build compiletest"), @@ -148,7 +149,16 @@ declare_tests!( (x_check_library, "check library"), (x_check_rustc, "check rustc"), (x_check_rustdoc, "check rustdoc"), + (x_clean, "clean"), + (x_clippy, "clippy"), (x_dist, "dist"), + (x_doc, "doc"), + (x_fix, "fix"), + (x_fmt, "fmt"), + (x_install, "install"), + (x_miri, "miri"), + (x_run, "run"), + (x_setup, "setup"), (x_test, "test"), (x_test_coverage, "test coverage"), (x_test_coverage_map, "test coverage-map"), @@ -174,5 +184,6 @@ declare_tests!( (x_test_tidy, "test tidy"), (x_test_tidyselftest, "test tidyselftest"), (x_test_ui, "test ui"), + (x_vendor, "vendor"), // tidy-alphabetical-end ); diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 9124442e7f376..18189a6d49969 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -5,7 +5,7 @@ use std::fmt::{Debug, Write}; use std::hash::Hash; use std::ops::Deref; use std::path::{Path, PathBuf}; -use std::sync::{LazyLock, OnceLock}; +use std::sync::OnceLock; use std::time::{Duration, Instant}; use std::{env, fs}; @@ -101,13 +101,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// Result type of `Step::run`. type Output: Clone; - /// Whether this step is run by default as part of its respective phase, as defined by the `describe` - /// macro in [`Builder::get_step_descriptions`]. - /// - /// Note: Even if set to `true`, it can still be overridden with [`ShouldRun::default_condition`] - /// by `Step::should_run`. - const DEFAULT: 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. @@ -116,6 +109,27 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// `--target` was specified, but `--host` was explicitly set to '' (empty string). const IS_HOST: bool = false; + /// Called to allow steps to register the command-line paths that should + /// cause them to run. + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>; + + /// 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. + fn is_default_step(_builder: &Builder<'_>) -> bool { + false + } + /// Primary function to implement `Step` logic. /// /// This function can be triggered in two ways: @@ -131,9 +145,6 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { /// depending on the `Step::run` implementation of the caller. fn run(self, builder: &Builder<'_>) -> Self::Output; - /// Determines if this `Step` should be run when given specific paths (e.g., `x build $path`). - fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>; - /// Called directly by the bootstrap `Step` handler when not triggered indirectly by other `Step`s 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`]. @@ -313,9 +324,9 @@ pub fn crate_description(crates: &[impl AsRef]) -> String { } struct StepDescription { - default: bool, is_host: bool, should_run: fn(ShouldRun<'_>) -> ShouldRun<'_>, + is_default_step_fn: fn(&Builder<'_>) -> bool, make_run: fn(RunConfig<'_>), name: &'static str, kind: Kind, @@ -434,9 +445,9 @@ impl PathSet { impl StepDescription { fn from(kind: Kind) -> StepDescription { StepDescription { - default: S::DEFAULT, is_host: S::IS_HOST, should_run: S::should_run, + is_default_step_fn: S::is_default_step, make_run: S::make_run, name: std::any::type_name::(), kind, @@ -488,48 +499,23 @@ impl StepDescription { } } -enum ReallyDefault<'a> { - Bool(bool), - Lazy(LazyLock bool + 'a>>), -} - +/// Builder that allows steps to register command-line paths/aliases that +/// should cause those steps to be run. +/// +/// For example, if the user invokes `./x test compiler` or `./x doc unstable-book`, +/// this allows bootstrap to determine what steps "compiler" or "unstable-book" +/// correspond to. pub struct ShouldRun<'a> { pub builder: &'a Builder<'a>, kind: Kind, // use a BTreeSet to maintain sort order paths: BTreeSet, - - // If this is a default rule, this is an additional constraint placed on - // its run. Generally something like compiler docs being enabled. - is_really_default: ReallyDefault<'a>, } impl<'a> ShouldRun<'a> { fn new(builder: &'a Builder<'_>, kind: Kind) -> ShouldRun<'a> { - ShouldRun { - builder, - kind, - paths: BTreeSet::new(), - is_really_default: ReallyDefault::Bool(true), // by default no additional conditions - } - } - - pub fn default_condition(mut self, cond: bool) -> Self { - self.is_really_default = ReallyDefault::Bool(cond); - self - } - - pub fn lazy_default_condition(mut self, lazy_cond: Box bool + 'a>) -> Self { - self.is_really_default = ReallyDefault::Lazy(LazyLock::new(lazy_cond)); - self - } - - pub fn is_really_default(&self) -> bool { - match &self.is_really_default { - ReallyDefault::Bool(val) => *val, - ReallyDefault::Lazy(lazy) => *lazy.deref(), - } + ShouldRun { builder, kind, paths: BTreeSet::new() } } /// Indicates it should run if the command-line selects the given crate or @@ -1648,7 +1634,7 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler } // Only execute if it's supposed to run as default - if desc.default && should_run.is_really_default() { Some(self.ensure(step)) } else { None } + if (desc.is_default_step_fn)(self) { Some(self.ensure(step)) } else { None } } /// Checks if any of the "should_run" paths is in the `Builder` paths.