Add build.tools option to manage installation of extended rust tools.

This commit is contained in:
O01eg 2018-02-05 20:10:05 +03:00
parent dd29d3dd76
commit 7be8e2fbb3
No known key found for this signature in database
GPG Key ID: D1A94F2400FBC7E5
4 changed files with 23 additions and 8 deletions

View File

@ -151,6 +151,10 @@
# default. # default.
#extended = false #extended = false
# Installs choosen set of extended tools if enables. By default builds all.
# If choosen tool failed to build the installation fails.
#tools = ["cargo", "rls", "rustfmt", "analysis", "src"]
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
#verbose = 0 #verbose = 0

View File

@ -13,7 +13,7 @@
//! This module implements parsing `config.toml` configuration files to tweak //! This module implements parsing `config.toml` configuration files to tweak
//! how the build runs. //! how the build runs.
use std::collections::HashMap; use std::collections::{HashMap, HashSet};
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::prelude::*; use std::io::prelude::*;
@ -52,6 +52,7 @@ pub struct Config {
pub target_config: HashMap<Interned<String>, Target>, pub target_config: HashMap<Interned<String>, Target>,
pub full_bootstrap: bool, pub full_bootstrap: bool,
pub extended: bool, pub extended: bool,
pub tools: Option<HashSet<String>>,
pub sanitizers: bool, pub sanitizers: bool,
pub profiler: bool, pub profiler: bool,
pub ignore_git: bool, pub ignore_git: bool,
@ -191,6 +192,7 @@ struct Build {
python: Option<String>, python: Option<String>,
full_bootstrap: Option<bool>, full_bootstrap: Option<bool>,
extended: Option<bool>, extended: Option<bool>,
tools: Option<HashSet<String>>,
verbose: Option<usize>, verbose: Option<usize>,
sanitizers: Option<bool>, sanitizers: Option<bool>,
profiler: Option<bool>, profiler: Option<bool>,
@ -395,6 +397,7 @@ impl Config {
set(&mut config.vendor, build.vendor); set(&mut config.vendor, build.vendor);
set(&mut config.full_bootstrap, build.full_bootstrap); set(&mut config.full_bootstrap, build.full_bootstrap);
set(&mut config.extended, build.extended); set(&mut config.extended, build.extended);
config.tools = build.tools;
set(&mut config.verbose, build.verbose); set(&mut config.verbose, build.verbose);
set(&mut config.sanitizers, build.sanitizers); set(&mut config.sanitizers, build.sanitizers);
set(&mut config.profiler, build.profiler); set(&mut config.profiler, build.profiler);

View File

@ -144,6 +144,7 @@ o("jemalloc", "rust.use-jemalloc", "build liballoc with jemalloc")
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two") o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two")
o("extended", "build.extended", "build an extended rust tool set") o("extended", "build.extended", "build an extended rust tool set")
v("tools", "build.tools", "List of extended tools will be installed")
v("build", "build.build", "GNUs ./configure syntax LLVM build triple") v("build", "build.build", "GNUs ./configure syntax LLVM build triple")
v("host", None, "GNUs ./configure syntax LLVM host triples") v("host", None, "GNUs ./configure syntax LLVM host triples")
v("target", None, "GNUs ./configure syntax LLVM target triples") v("target", None, "GNUs ./configure syntax LLVM target triples")

View File

@ -185,32 +185,39 @@ install!((self, builder, _config),
install_std(builder, self.stage, *target); install_std(builder, self.stage, *target);
} }
}; };
Cargo, "cargo", _config.extended, only_hosts: true, { Cargo, "cargo", _config.extended &&
_config.tools.as_ref().map_or(true, |t| t.contains("cargo")), only_hosts: true, {
builder.ensure(dist::Cargo { stage: self.stage, target: self.target }); builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
install_cargo(builder, self.stage, self.target); install_cargo(builder, self.stage, self.target);
}; };
Rls, "rls", _config.extended, only_hosts: true, { Rls, "rls", _config.extended &&
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() { _config.tools.as_ref().map_or(true, |t| t.contains("rls")), only_hosts: true, {
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() ||
builder.config.tools.as_ref().map_or(false, |t| t.contains("rls")) {
install_rls(builder, self.stage, self.target); install_rls(builder, self.stage, self.target);
} else { } else {
println!("skipping Install RLS stage{} ({})", self.stage, self.target); println!("skipping Install RLS stage{} ({})", self.stage, self.target);
} }
}; };
Rustfmt, "rustfmt", _config.extended, only_hosts: true, { Rustfmt, "rustfmt", _config.extended &&
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() { _config.tools.as_ref().map_or(true, |t| t.contains("rustfmt")), only_hosts: true, {
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
builder.config.tools.as_ref().map_or(false, |t| t.contains("rustfmt")) {
install_rustfmt(builder, self.stage, self.target); install_rustfmt(builder, self.stage, self.target);
} else { } else {
println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target); println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
} }
}; };
Analysis, "analysis", _config.extended, only_hosts: false, { Analysis, "analysis", _config.extended &&
_config.tools.as_ref().map_or(true, |t| t.contains("analysis")), only_hosts: false, {
builder.ensure(dist::Analysis { builder.ensure(dist::Analysis {
compiler: builder.compiler(self.stage, self.host), compiler: builder.compiler(self.stage, self.host),
target: self.target target: self.target
}); });
install_analysis(builder, self.stage, self.target); install_analysis(builder, self.stage, self.target);
}; };
Src, "src", _config.extended, only_hosts: true, { Src, "src", _config.extended &&
_config.tools.as_ref().map_or(true, |t| t.contains("src")), only_hosts: true, {
builder.ensure(dist::Src); builder.ensure(dist::Src);
install_src(builder, self.stage); install_src(builder, self.stage);
}, ONLY_BUILD; }, ONLY_BUILD;