]> git.lizzy.rs Git - rust.git/commitdiff
Move code out of macro and into generic method.
authorMark Simulacrum <mark.simulacrum@gmail.com>
Thu, 6 Jul 2017 15:15:08 +0000 (09:15 -0600)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Thu, 20 Jul 2017 17:23:58 +0000 (11:23 -0600)
src/bootstrap/builder.rs

index 589401ea24e2c8e7093ac8189dc013244ae167c4..eceb68d1f4dd84e9d42f22d91fdd738402f70bf6 100644 (file)
@@ -81,57 +81,19 @@ pub enum Kind {
 }
 
 macro_rules! check {
-    (@inner $self:ident, $rule:ty, $path:expr) => {
-        let build = $self.build;
-        let hosts = if <$rule>::ONLY_BUILD_TARGETS || <$rule>::ONLY_BUILD {
-            &build.config.host[..1]
-        } else {
-            &build.hosts
-        };
-
-        // Determine the actual targets participating in this rule.
-        // NOTE: We should keep the full projection from build triple to
-        // the hosts for the dist steps, now that the hosts array above is
-        // truncated to avoid duplication of work in that case. Therefore
-        // the original non-shadowed hosts array is used below.
-        let targets = if <$rule>::ONLY_HOSTS {
-            // If --target was specified but --host wasn't specified,
-            // don't run any host-only tests. Also, respect any `--host`
-            // overrides as done for `hosts`.
-            if build.flags.host.len() > 0 {
-                &build.flags.host[..]
-            } else if build.flags.target.len() > 0 {
-                &[]
-            } else if <$rule>::ONLY_BUILD {
-                &build.config.host[..1]
-            } else {
-                &build.config.host[..]
-            }
-        } else {
-            &build.targets
-        };
-
-        build.verbose(&format!("executing {} with hosts={:?}, targets={:?}",
-            stringify!($rule), hosts, targets));
-        for host in hosts {
-            for target in targets {
-                <$rule>::make_run($self, $path, host, target);
-            }
-        }
-    };
     ($self:ident, $paths:ident, $($rule:ty),+ $(,)*) => {{
         let paths = $paths;
         if paths.is_empty() {
             $({
                 if <$rule>::DEFAULT {
-                    check!(@inner $self, $rule, None);
+                    $self.maybe_run::<$rule>(None);
                 }
             })+
         } else {
             for path in paths {
                 $({
                     if <$rule>::should_run($self, path) {
-                        check!(@inner $self, $rule, Some(path));
+                        $self.maybe_run::<$rule>(Some(path));
                     }
                 })+
             }
@@ -427,6 +389,43 @@ pub fn cargo(&self,
         cargo
     }
 
+    fn maybe_run<S: Step<'a>>(&'a self, path: Option<&Path>) {
+        let build = self.build;
+        let hosts = if S::ONLY_BUILD_TARGETS || S::ONLY_BUILD {
+            &build.config.host[..1]
+        } else {
+            &build.hosts
+        };
+
+        // Determine the actual targets participating in this rule.
+        // NOTE: We should keep the full projection from build triple to
+        // the hosts for the dist steps, now that the hosts array above is
+        // truncated to avoid duplication of work in that case. Therefore
+        // the original non-shadowed hosts array is used below.
+        let targets = if S::ONLY_HOSTS {
+            // If --target was specified but --host wasn't specified,
+            // don't run any host-only tests. Also, respect any `--host`
+            // overrides as done for `hosts`.
+            if build.flags.host.len() > 0 {
+                &build.flags.host[..]
+            } else if build.flags.target.len() > 0 {
+                &[]
+            } else if S::ONLY_BUILD {
+                &build.config.host[..1]
+            } else {
+                &build.config.host[..]
+            }
+        } else {
+            &build.targets
+        };
+
+        for host in hosts {
+            for target in targets {
+                S::make_run(self, path, host, target);
+            }
+        }
+    }
+
     pub fn ensure<S: Step<'a> + Serialize>(&'a self, step: S) -> S::Output
     where
         S::Output: 'a