]>
Commit | Line | Data |
---|---|---|
ba9703b0 | 1 | use crate::builder::{Builder, RunConfig, ShouldRun, Step}; |
1b1a35ee | 2 | use crate::dist::distdir; |
ba9703b0 | 3 | use crate::tool::Tool; |
1b1a35ee | 4 | use build_helper::output; |
ba9703b0 XL |
5 | use std::process::Command; |
6 | ||
7 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | |
8 | pub struct ExpandYamlAnchors; | |
9 | ||
10 | impl Step for ExpandYamlAnchors { | |
11 | type Output = (); | |
12 | ||
13 | /// Runs the `expand-yaml_anchors` tool. | |
14 | /// | |
1b1a35ee | 15 | /// This tool in `src/tools` reads the CI configuration files written in YAML and expands the |
ba9703b0 XL |
16 | /// anchors in them, since GitHub Actions doesn't support them. |
17 | fn run(self, builder: &Builder<'_>) { | |
18 | builder.info("Expanding YAML anchors in the GitHub Actions configuration"); | |
19 | try_run( | |
20 | builder, | |
21 | &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src), | |
22 | ); | |
23 | } | |
24 | ||
25 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
26 | run.path("src/tools/expand-yaml-anchors") | |
27 | } | |
28 | ||
29 | fn make_run(run: RunConfig<'_>) { | |
30 | run.builder.ensure(ExpandYamlAnchors); | |
31 | } | |
32 | } | |
33 | ||
34 | fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool { | |
35 | if !builder.fail_fast { | |
36 | if !builder.try_run(cmd) { | |
37 | let mut failures = builder.delayed_failures.borrow_mut(); | |
38 | failures.push(format!("{:?}", cmd)); | |
39 | return false; | |
40 | } | |
41 | } else { | |
42 | builder.run(cmd); | |
43 | } | |
44 | true | |
45 | } | |
1b1a35ee XL |
46 | |
47 | #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)] | |
48 | pub struct BuildManifest; | |
49 | ||
50 | impl Step for BuildManifest { | |
51 | type Output = (); | |
52 | const ONLY_HOSTS: bool = true; | |
53 | ||
54 | fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { | |
55 | run.path("src/tools/build-manifest") | |
56 | } | |
57 | ||
58 | fn make_run(run: RunConfig<'_>) { | |
59 | run.builder.ensure(BuildManifest); | |
60 | } | |
61 | ||
62 | fn run(self, builder: &Builder<'_>) { | |
63 | // This gets called by `promote-release` | |
64 | // (https://github.com/rust-lang/promote-release). | |
65 | let mut cmd = builder.tool_cmd(Tool::BuildManifest); | |
66 | let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| { | |
67 | panic!("\n\nfailed to specify `dist.sign-folder` in `config.toml`\n\n") | |
68 | }); | |
69 | let addr = builder.config.dist_upload_addr.as_ref().unwrap_or_else(|| { | |
70 | panic!("\n\nfailed to specify `dist.upload-addr` in `config.toml`\n\n") | |
71 | }); | |
72 | ||
73 | let today = output(Command::new("date").arg("+%Y-%m-%d")); | |
74 | ||
75 | cmd.arg(sign); | |
76 | cmd.arg(distdir(builder)); | |
77 | cmd.arg(today.trim()); | |
78 | cmd.arg(addr); | |
79 | cmd.arg(&builder.config.channel); | |
80 | ||
81 | builder.create_dir(&distdir(builder)); | |
82 | builder.run(&mut cmd); | |
83 | } | |
84 | } |