1 use crate::builder::{Builder, RunConfig, ShouldRun, Step};
2 use crate::dist::distdir;
4 use build_helper::output;
5 use std::process::Command;
7 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
8 pub struct ExpandYamlAnchors;
10 impl Step for ExpandYamlAnchors {
13 /// Runs the `expand-yaml_anchors` tool.
15 /// This tool in `src/tools` reads the CI configuration files written in YAML and expands the
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");
21 &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
25 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
26 run.path("src/tools/expand-yaml-anchors")
29 fn make_run(run: RunConfig<'_>) {
30 run.builder.ensure(ExpandYamlAnchors);
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));
47 #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
48 pub struct BuildManifest;
50 impl Step for BuildManifest {
52 const ONLY_HOSTS: bool = true;
54 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
55 run.path("src/tools/build-manifest")
58 fn make_run(run: RunConfig<'_>) {
59 run.builder.ensure(BuildManifest);
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")
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")
73 let today = output(Command::new("date").arg("+%Y-%m-%d"));
76 cmd.arg(distdir(builder));
77 cmd.arg(today.trim());
79 cmd.arg(&builder.config.channel);
81 builder.create_dir(&distdir(builder));
82 builder.run(&mut cmd);