]> git.lizzy.rs Git - rust.git/blob - src/bootstrap/run.rs
Deal with spaces in the rust version.
[rust.git] / src / bootstrap / run.rs
1 use crate::builder::{Builder, RunConfig, ShouldRun, Step};
2 use crate::tool::Tool;
3 use std::process::Command;
4
5 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
6 pub struct ExpandYamlAnchors;
7
8 impl Step for ExpandYamlAnchors {
9     type Output = ();
10
11     /// Runs the `expand-yaml_anchors` tool.
12     ///
13     /// This tool in `src/tools` read the CI configuration files written in YAML and expands the
14     /// anchors in them, since GitHub Actions doesn't support them.
15     fn run(self, builder: &Builder<'_>) {
16         builder.info("Expanding YAML anchors in the GitHub Actions configuration");
17         try_run(
18             builder,
19             &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
20         );
21     }
22
23     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
24         run.path("src/tools/expand-yaml-anchors")
25     }
26
27     fn make_run(run: RunConfig<'_>) {
28         run.builder.ensure(ExpandYamlAnchors);
29     }
30 }
31
32 fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
33     if !builder.fail_fast {
34         if !builder.try_run(cmd) {
35             let mut failures = builder.delayed_failures.borrow_mut();
36             failures.push(format!("{:?}", cmd));
37             return false;
38         }
39     } else {
40         builder.run(cmd);
41     }
42     true
43 }