Skip to content

Commit 7be8e2f

Browse files
committed
Add build.tools option to manage installation of extended rust tools.
1 parent dd29d3d commit 7be8e2f

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-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

+14-7
Original file line numberDiff line numberDiff line change
@@ -185,32 +185,39 @@ install!((self, builder, _config),
185185
install_std(builder, self.stage, *target);
186186
}
187187
};
188-
Cargo, "cargo", _config.extended, only_hosts: true, {
188+
Cargo, "cargo", _config.extended &&
189+
_config.tools.as_ref().map_or(true, |t| t.contains("cargo")), only_hosts: true, {
189190
builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
190191
install_cargo(builder, self.stage, self.target);
191192
};
192-
Rls, "rls", _config.extended, only_hosts: true, {
193-
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() {
193+
Rls, "rls", _config.extended &&
194+
_config.tools.as_ref().map_or(true, |t| t.contains("rls")), only_hosts: true, {
195+
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() ||
196+
builder.config.tools.as_ref().map_or(false, |t| t.contains("rls")) {
194197
install_rls(builder, self.stage, self.target);
195198
} else {
196199
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
197200
}
198201
};
199-
Rustfmt, "rustfmt", _config.extended, only_hosts: true, {
200-
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() {
202+
Rustfmt, "rustfmt", _config.extended &&
203+
_config.tools.as_ref().map_or(true, |t| t.contains("rustfmt")), only_hosts: true, {
204+
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
205+
builder.config.tools.as_ref().map_or(false, |t| t.contains("rustfmt")) {
201206
install_rustfmt(builder, self.stage, self.target);
202207
} else {
203208
println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
204209
}
205210
};
206-
Analysis, "analysis", _config.extended, only_hosts: false, {
211+
Analysis, "analysis", _config.extended &&
212+
_config.tools.as_ref().map_or(true, |t| t.contains("analysis")), only_hosts: false, {
207213
builder.ensure(dist::Analysis {
208214
compiler: builder.compiler(self.stage, self.host),
209215
target: self.target
210216
});
211217
install_analysis(builder, self.stage, self.target);
212218
};
213-
Src, "src", _config.extended, only_hosts: true, {
219+
Src, "src", _config.extended &&
220+
_config.tools.as_ref().map_or(true, |t| t.contains("src")), only_hosts: true, {
214221
builder.ensure(dist::Src);
215222
install_src(builder, self.stage);
216223
}, ONLY_BUILD;

0 commit comments

Comments
 (0)