Skip to content

Commit 78a0b7f

Browse files
committed
Refactor checks on list of extended tools.
1 parent 7be8e2f commit 78a0b7f

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/bootstrap/install.rs

+21-12
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,39 +199,34 @@ install!((self, builder, _config),
185199
install_std(builder, self.stage, *target);
186200
}
187201
};
188-
Cargo, "cargo", _config.extended &&
189-
_config.tools.as_ref().map_or(true, |t| t.contains("cargo")), only_hosts: true, {
202+
Cargo, "cargo", Self::should_build(_config), only_hosts: true, {
190203
builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
191204
install_cargo(builder, self.stage, self.target);
192205
};
193-
Rls, "rls", _config.extended &&
194-
_config.tools.as_ref().map_or(true, |t| t.contains("rls")), only_hosts: true, {
206+
Rls, "rls", Self::should_build(_config), only_hosts: true, {
195207
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")) {
208+
Self::should_install(builder) {
197209
install_rls(builder, self.stage, self.target);
198210
} else {
199211
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
200212
}
201213
};
202-
Rustfmt, "rustfmt", _config.extended &&
203-
_config.tools.as_ref().map_or(true, |t| t.contains("rustfmt")), only_hosts: true, {
214+
Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
204215
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")) {
216+
Self::should_install(builder) {
206217
install_rustfmt(builder, self.stage, self.target);
207218
} else {
208219
println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
209220
}
210221
};
211-
Analysis, "analysis", _config.extended &&
212-
_config.tools.as_ref().map_or(true, |t| t.contains("analysis")), only_hosts: false, {
222+
Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
213223
builder.ensure(dist::Analysis {
214224
compiler: builder.compiler(self.stage, self.host),
215225
target: self.target
216226
});
217227
install_analysis(builder, self.stage, self.target);
218228
};
219-
Src, "src", _config.extended &&
220-
_config.tools.as_ref().map_or(true, |t| t.contains("src")), only_hosts: true, {
229+
Src, "src", Self::should_build(_config) , only_hosts: true, {
221230
builder.ensure(dist::Src);
222231
install_src(builder, self.stage);
223232
}, ONLY_BUILD;

0 commit comments

Comments
 (0)