diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-07-14 11:04:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-14 11:04:54 +0200 |
| commit | 197ba7e4f16fd72830f9fb65367eb68603a11f03 (patch) | |
| tree | 6217904d495ac0c100f597dd056bf7e76a73980c /src/bootstrap | |
| parent | 0d4d85b9eaaafa498721fdce4f7d59bfadef4363 (diff) | |
| parent | 940aa204086ad4efa3b5151b1363610c9ccf28d9 (diff) | |
| download | rust-197ba7e4f16fd72830f9fb65367eb68603a11f03.tar.gz rust-197ba7e4f16fd72830f9fb65367eb68603a11f03.zip | |
Rollup merge of #143733 - Stypox:bootstrap-tool-config-any, r=Kobzol
Change bootstrap's `tool.TOOL_NAME.features` to work on any subcommand This is a followup to rust-lang/rust#142379 to make the bootstrap option `tool.TOOL_NAME.features` work on any subcommand instead of just build (so also run/test/...). I also made the `TOOL_NAME` comparisons look at the tool path instead of the tool name to determine to which tool a `TOOL_NAME` refers to, so you can specify tools by path like in other places of the bootstrap (e.g. `tool."tools/miri".features`).
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/tool.rs | 31 | ||||
| -rw-r--r-- | src/bootstrap/src/utils/change_tracker.rs | 5 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 02241b3e697..814a44b9a13 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -9,6 +9,7 @@ //! Each Rust tool **MUST** utilize `ToolBuild` inside their `Step` logic, //! return `ToolBuildResult` and should never prepare `cargo` invocations manually. +use std::ffi::OsStr; use std::path::PathBuf; use std::{env, fs}; @@ -136,19 +137,6 @@ impl Step for ToolBuild { _ => panic!("unexpected Mode for tool build"), } - // build.tool.TOOL_NAME.features in bootstrap.toml allows specifying which features to - // enable for a specific tool. `extra_features` instead is not controlled by the toml and - // provides features that are always enabled for a specific tool (e.g. "in-rust-tree" for - // rust-analyzer). Finally, `prepare_tool_cargo` might add more features to adapt the build - // to the chosen flags (e.g. "all-static" for cargo if `cargo_native_static` is true). - let mut features = builder - .config - .tool - .get(self.tool) - .and_then(|tool| tool.features.clone()) - .unwrap_or_default(); - features.extend(self.extra_features.clone()); - let mut cargo = prepare_tool_cargo( builder, self.compiler, @@ -157,7 +145,7 @@ impl Step for ToolBuild { Kind::Build, path, self.source_type, - &features, + &self.extra_features, ); // The stage0 compiler changes infrequently and does not directly depend on code @@ -244,7 +232,8 @@ pub fn prepare_tool_cargo( ) -> CargoCommand { let mut cargo = builder::Cargo::new(builder, compiler, mode, source_type, target, cmd_kind); - let dir = builder.src.join(path); + let path = PathBuf::from(path); + let dir = builder.src.join(&path); cargo.arg("--manifest-path").arg(dir.join("Cargo.toml")); let mut features = extra_features.to_vec(); @@ -261,6 +250,18 @@ pub fn prepare_tool_cargo( } } + // build.tool.TOOL_NAME.features in bootstrap.toml allows specifying which features to enable + // for a specific tool. `extra_features` instead is not controlled by the toml and provides + // features that are always enabled for a specific tool (e.g. "in-rust-tree" for rust-analyzer). + // Finally, `prepare_tool_cargo` above here might add more features to adapt the build + // to the chosen flags (e.g. "all-static" for cargo if `cargo_native_static` is true). + builder + .config + .tool + .iter() + .filter(|(tool_name, _)| path.file_name().and_then(OsStr::to_str) == Some(tool_name)) + .for_each(|(_, tool)| features.extend(tool.features.clone().unwrap_or_default())); + // clippy tests need to know about the stage sysroot. Set them consistently while building to // avoid rebuilding when running tests. cargo.env("SYSROOT", builder.sysroot(compiler)); diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index c5d460ac55b..1f6ed8129da 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -471,4 +471,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Info, summary: "A --compile-time-deps flag has been added to reduce the time it takes rust-analyzer to start", }, + ChangeInfo { + change_id: 143733, + severity: ChangeSeverity::Info, + summary: "Option `tool.TOOL_NAME.features` now works on any subcommand, not just `build`.", + }, ]; |
