about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorO01eg <o01eg@yandex.ru>2018-02-07 20:57:02 +0300
committerO01eg <o01eg@yandex.ru>2018-02-07 20:57:02 +0300
commit78a0b7fd466093003841cec6fd20d65270cf2175 (patch)
tree015df3a72d799aee405b5db0f77a39f3d9181fb2 /src/bootstrap
parent7be8e2fbb3745602ac864fc079a040dd3a80d91d (diff)
downloadrust-78a0b7fd466093003841cec6fd20d65270cf2175.tar.gz
rust-78a0b7fd466093003841cec6fd20d65270cf2175.zip
Refactor checks on list of extended tools.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/install.rs33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
index 86df36f209e..20f7d379a69 100644
--- a/src/bootstrap/install.rs
+++ b/src/bootstrap/install.rs
@@ -22,6 +22,7 @@ use dist::{self, pkgname, sanitize_sh, tmpdir};
 
 use builder::{Builder, RunConfig, ShouldRun, Step};
 use cache::Interned;
+use config::Config;
 
 pub fn install_docs(builder: &Builder, stage: u32, host: Interned<String>) {
     install_sh(builder, "docs", "rust-docs", stage, Some(host));
@@ -144,6 +145,19 @@ macro_rules! install {
             pub host: Interned<String>,
         }
 
+        impl $name {
+            #[allow(dead_code)]
+            fn should_build(config: &Config) -> bool {
+                config.extended && config.tools.as_ref()
+                    .map_or(true, |t| t.contains($path))
+            }
+
+            #[allow(dead_code)]
+            fn should_install(builder: &Builder) -> bool {
+                builder.config.tools.as_ref().map_or(false, |t| t.contains($path))
+            }
+        }
+
         impl Step for $name {
             type Output = ();
             const DEFAULT: bool = true;
@@ -185,39 +199,34 @@ install!((self, builder, _config),
             install_std(builder, self.stage, *target);
         }
     };
-    Cargo, "cargo", _config.extended &&
-            _config.tools.as_ref().map_or(true, |t| t.contains("cargo")), only_hosts: true, {
+    Cargo, "cargo", Self::should_build(_config), only_hosts: true, {
         builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
         install_cargo(builder, self.stage, self.target);
     };
-    Rls, "rls", _config.extended &&
-            _config.tools.as_ref().map_or(true, |t| t.contains("rls")), only_hosts: true, {
+    Rls, "rls", Self::should_build(_config), 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")) {
+            Self::should_install(builder) {
             install_rls(builder, self.stage, self.target);
         } else {
             println!("skipping Install RLS stage{} ({})", self.stage, self.target);
         }
     };
-    Rustfmt, "rustfmt", _config.extended &&
-            _config.tools.as_ref().map_or(true, |t| t.contains("rustfmt")), only_hosts: true, {
+    Rustfmt, "rustfmt", Self::should_build(_config), 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"))  {
+            Self::should_install(builder) {
             install_rustfmt(builder, self.stage, self.target);
         } else {
             println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
         }
     };
-    Analysis, "analysis", _config.extended &&
-            _config.tools.as_ref().map_or(true, |t| t.contains("analysis")), only_hosts: false, {
+    Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
         builder.ensure(dist::Analysis {
             compiler: builder.compiler(self.stage, self.host),
             target: self.target
         });
         install_analysis(builder, self.stage, self.target);
     };
-    Src, "src", _config.extended &&
-            _config.tools.as_ref().map_or(true, |t| t.contains("src")), only_hosts: true, {
+    Src, "src", Self::should_build(_config) , only_hosts: true, {
         builder.ensure(dist::Src);
         install_src(builder, self.stage);
     }, ONLY_BUILD;