Skip to content

Commit ebbc35b

Browse files
authored
Rollup merge of rust-lang#48015 - o01eg:disableable-installation, r=alexcrichton
Customizable extended tools This PR adds `build.tools` option to manage installation of extended rust tools. By default it doesn't change installation. All tools are built and `rls` and `rustfmt` allowed to fail installation. If some set of tools chosen only those tools are built and installed without any fails allowed. It solves some slotting issues with extended build enabled: https://bugs.gentoo.org/show_bug.cgi?id=645498
2 parents 7c17ac8 + 78a0b7f commit ebbc35b

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@
151151
# default.
152152
#extended = false
153153

154+
# Installs choosen set of extended tools if enables. By default builds all.
155+
# If choosen tool failed to build the installation fails.
156+
#tools = ["cargo", "rls", "rustfmt", "analysis", "src"]
157+
154158
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
155159
#verbose = 0
156160

src/bootstrap/config.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! This module implements parsing `config.toml` configuration files to tweak
1414
//! how the build runs.
1515
16-
use std::collections::HashMap;
16+
use std::collections::{HashMap, HashSet};
1717
use std::env;
1818
use std::fs::File;
1919
use std::io::prelude::*;
@@ -52,6 +52,7 @@ pub struct Config {
5252
pub target_config: HashMap<Interned<String>, Target>,
5353
pub full_bootstrap: bool,
5454
pub extended: bool,
55+
pub tools: Option<HashSet<String>>,
5556
pub sanitizers: bool,
5657
pub profiler: bool,
5758
pub ignore_git: bool,
@@ -191,6 +192,7 @@ struct Build {
191192
python: Option<String>,
192193
full_bootstrap: Option<bool>,
193194
extended: Option<bool>,
195+
tools: Option<HashSet<String>>,
194196
verbose: Option<usize>,
195197
sanitizers: Option<bool>,
196198
profiler: Option<bool>,
@@ -395,6 +397,7 @@ impl Config {
395397
set(&mut config.vendor, build.vendor);
396398
set(&mut config.full_bootstrap, build.full_bootstrap);
397399
set(&mut config.extended, build.extended);
400+
config.tools = build.tools;
398401
set(&mut config.verbose, build.verbose);
399402
set(&mut config.sanitizers, build.sanitizers);
400403
set(&mut config.profiler, build.profiler);

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def v(*args):
144144
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two")
145145
o("extended", "build.extended", "build an extended rust tool set")
146146

147+
v("tools", "build.tools", "List of extended tools will be installed")
147148
v("build", "build.build", "GNUs ./configure syntax LLVM build triple")
148149
v("host", None, "GNUs ./configure syntax LLVM host triples")
149150
v("target", None, "GNUs ./configure syntax LLVM target triples")

src/bootstrap/install.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use dist::{self, pkgname, sanitize_sh, tmpdir};
2222

2323
use builder::{Builder, RunConfig, ShouldRun, Step};
2424
use cache::Interned;
25+
use config::Config;
2526

2627
pub fn install_docs(builder: &Builder, stage: u32, host: Interned<String>) {
2728
install_sh(builder, "docs", "rust-docs", stage, Some(host));
@@ -144,6 +145,19 @@ macro_rules! install {
144145
pub host: Interned<String>,
145146
}
146147

148+
impl $name {
149+
#[allow(dead_code)]
150+
fn should_build(config: &Config) -> bool {
151+
config.extended && config.tools.as_ref()
152+
.map_or(true, |t| t.contains($path))
153+
}
154+
155+
#[allow(dead_code)]
156+
fn should_install(builder: &Builder) -> bool {
157+
builder.config.tools.as_ref().map_or(false, |t| t.contains($path))
158+
}
159+
}
160+
147161
impl Step for $name {
148162
type Output = ();
149163
const DEFAULT: bool = true;
@@ -185,32 +199,34 @@ install!((self, builder, _config),
185199
install_std(builder, self.stage, *target);
186200
}
187201
};
188-
Cargo, "cargo", _config.extended, only_hosts: true, {
202+
Cargo, "cargo", Self::should_build(_config), only_hosts: true, {
189203
builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
190204
install_cargo(builder, self.stage, self.target);
191205
};
192-
Rls, "rls", _config.extended, only_hosts: true, {
193-
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() {
206+
Rls, "rls", Self::should_build(_config), only_hosts: true, {
207+
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() ||
208+
Self::should_install(builder) {
194209
install_rls(builder, self.stage, self.target);
195210
} else {
196211
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
197212
}
198213
};
199-
Rustfmt, "rustfmt", _config.extended, only_hosts: true, {
200-
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() {
214+
Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
215+
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
216+
Self::should_install(builder) {
201217
install_rustfmt(builder, self.stage, self.target);
202218
} else {
203219
println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
204220
}
205221
};
206-
Analysis, "analysis", _config.extended, only_hosts: false, {
222+
Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
207223
builder.ensure(dist::Analysis {
208224
compiler: builder.compiler(self.stage, self.host),
209225
target: self.target
210226
});
211227
install_analysis(builder, self.stage, self.target);
212228
};
213-
Src, "src", _config.extended, only_hosts: true, {
229+
Src, "src", Self::should_build(_config) , only_hosts: true, {
214230
builder.ensure(dist::Src);
215231
install_src(builder, self.stage);
216232
}, ONLY_BUILD;

0 commit comments

Comments
 (0)