mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Add bootstrap option to compile a tool with features
This commit is contained in:
@@ -381,6 +381,14 @@
|
||||
# "miri", "cargo-miri" # for dev/nightly channels
|
||||
#]
|
||||
|
||||
# Specify build configuration specific for some tool, such as enabled features.
|
||||
#
|
||||
# For example, to build Miri with tracing support, use `tool-config.miri.features = ["tracing"]`
|
||||
#
|
||||
# The default value for the `features` array is `[]`. However, please note that other flags in
|
||||
# `bootstrap.toml` might influence the features enabled for some tools.
|
||||
#tool-config.TOOL_NAME.features = [FEATURE1, FEATURE2]
|
||||
|
||||
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose, 3 == print environment variables on each rustc invocation
|
||||
#verbose = 0
|
||||
|
||||
|
||||
@@ -136,6 +136,20 @@ fn run(mut self, builder: &Builder<'_>) -> ToolBuildResult {
|
||||
_ => panic!("unexpected Mode for tool build"),
|
||||
}
|
||||
|
||||
// build.tool-config.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
|
||||
// instead 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_config
|
||||
.get(self.tool)
|
||||
.and_then(|tool_config| tool_config.features.clone())
|
||||
.unwrap_or_default();
|
||||
features.extend(self.extra_features.clone());
|
||||
|
||||
let mut cargo = prepare_tool_cargo(
|
||||
builder,
|
||||
self.compiler,
|
||||
@@ -144,7 +158,7 @@ fn run(mut self, builder: &Builder<'_>) -> ToolBuildResult {
|
||||
Kind::Build,
|
||||
path,
|
||||
self.source_type,
|
||||
&self.extra_features,
|
||||
&features,
|
||||
);
|
||||
|
||||
// The stage0 compiler changes infrequently and does not directly depend on code
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
use crate::core::config::flags::{Color, Flags};
|
||||
use crate::core::config::target_selection::TargetSelectionList;
|
||||
use crate::core::config::toml::TomlConfig;
|
||||
use crate::core::config::toml::build::Build;
|
||||
use crate::core::config::toml::build::{Build, ToolConfig};
|
||||
use crate::core::config::toml::change_id::ChangeId;
|
||||
use crate::core::config::toml::rust::{
|
||||
LldMode, RustOptimize, check_incompatible_options_for_ci_rustc,
|
||||
@@ -114,6 +114,7 @@ pub struct Config {
|
||||
pub bootstrap_cache_path: Option<PathBuf>,
|
||||
pub extended: bool,
|
||||
pub tools: Option<HashSet<String>>,
|
||||
pub tool_config: HashMap<String, ToolConfig>,
|
||||
pub sanitizers: bool,
|
||||
pub profiler: bool,
|
||||
pub omit_git_hash: bool,
|
||||
@@ -689,6 +690,7 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
|
||||
bootstrap_cache_path,
|
||||
extended,
|
||||
tools,
|
||||
tool_config,
|
||||
verbose,
|
||||
sanitizers,
|
||||
profiler,
|
||||
@@ -835,6 +837,7 @@ fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {
|
||||
set(&mut config.full_bootstrap, full_bootstrap);
|
||||
set(&mut config.extended, extended);
|
||||
config.tools = tools;
|
||||
set(&mut config.tool_config, tool_config);
|
||||
set(&mut config.verbose, verbose);
|
||||
set(&mut config.sanitizers, sanitizers);
|
||||
set(&mut config.profiler, profiler);
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
//! various feature flags. These options apply across different stages and components
|
||||
//! unless specifically overridden by other configuration sections or command-line flags.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
use crate::core::config::toml::ReplaceOpt;
|
||||
@@ -42,6 +44,7 @@ struct Build {
|
||||
bootstrap_cache_path: Option<PathBuf> = "bootstrap-cache-path",
|
||||
extended: Option<bool> = "extended",
|
||||
tools: Option<HashSet<String>> = "tools",
|
||||
tool_config: Option<HashMap<String, ToolConfig>> = "tool-config",
|
||||
verbose: Option<usize> = "verbose",
|
||||
sanitizers: Option<bool> = "sanitizers",
|
||||
profiler: Option<bool> = "profiler",
|
||||
@@ -70,3 +73,10 @@ struct Build {
|
||||
exclude: Option<Vec<PathBuf>> = "exclude",
|
||||
}
|
||||
}
|
||||
|
||||
define_config! {
|
||||
#[derive(Default, Clone)]
|
||||
struct ToolConfig {
|
||||
features: Option<Vec<String>> = "features",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,4 +421,9 @@ pub fn human_readable_changes(changes: &[ChangeInfo]) -> String {
|
||||
severity: ChangeSeverity::Info,
|
||||
summary: "Added new bootstrap flag `--skip-std-check-if-no-download-rustc` that skips std checks when download-rustc is unavailable. Mainly intended for developers to reduce RA overhead.",
|
||||
},
|
||||
ChangeInfo {
|
||||
change_id: 142379,
|
||||
severity: ChangeSeverity::Info,
|
||||
summary: "Added new option `tool-config.TOOL_NAME.features` to specify the features to compile a tool with",
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user