1 use std::process::Command;
3 use crate::builder::{Builder, RunConfig, ShouldRun, Step};
4 use crate::config::TargetSelection;
5 use crate::dist::distdir;
7 use crate::tool::{self, SourceType, Tool};
8 use crate::util::output;
11 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
12 pub struct ExpandYamlAnchors;
14 impl Step for ExpandYamlAnchors {
17 /// Runs the `expand-yaml_anchors` tool.
19 /// This tool in `src/tools` reads the CI configuration files written in YAML and expands the
20 /// anchors in them, since GitHub Actions doesn't support them.
21 fn run(self, builder: &Builder<'_>) {
22 builder.info("Expanding YAML anchors in the GitHub Actions configuration");
25 &mut builder.tool_cmd(Tool::ExpandYamlAnchors).arg("generate").arg(&builder.src),
29 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
30 run.path("src/tools/expand-yaml-anchors")
33 fn make_run(run: RunConfig<'_>) {
34 run.builder.ensure(ExpandYamlAnchors);
38 fn try_run(builder: &Builder<'_>, cmd: &mut Command) -> bool {
39 if !builder.fail_fast {
40 if !builder.try_run(cmd) {
41 let mut failures = builder.delayed_failures.borrow_mut();
42 failures.push(format!("{:?}", cmd));
51 #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
52 pub struct BuildManifest;
54 impl Step for BuildManifest {
56 const ONLY_HOSTS: bool = true;
58 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
59 run.path("src/tools/build-manifest")
62 fn make_run(run: RunConfig<'_>) {
63 run.builder.ensure(BuildManifest);
66 fn run(self, builder: &Builder<'_>) {
67 // This gets called by `promote-release`
68 // (https://github.com/rust-lang/promote-release).
69 let mut cmd = builder.tool_cmd(Tool::BuildManifest);
70 let sign = builder.config.dist_sign_folder.as_ref().unwrap_or_else(|| {
71 panic!("\n\nfailed to specify `dist.sign-folder` in `config.toml`\n\n")
73 let addr = builder.config.dist_upload_addr.as_ref().unwrap_or_else(|| {
74 panic!("\n\nfailed to specify `dist.upload-addr` in `config.toml`\n\n")
77 let today = output(Command::new("date").arg("+%Y-%m-%d"));
80 cmd.arg(distdir(builder));
81 cmd.arg(today.trim());
83 cmd.arg(&builder.config.channel);
85 builder.create_dir(&distdir(builder));
86 builder.run(&mut cmd);
90 #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
91 pub struct BumpStage0;
93 impl Step for BumpStage0 {
95 const ONLY_HOSTS: bool = true;
97 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
98 run.path("src/tools/bump-stage0")
101 fn make_run(run: RunConfig<'_>) {
102 run.builder.ensure(BumpStage0);
105 fn run(self, builder: &Builder<'_>) -> Self::Output {
106 let mut cmd = builder.tool_cmd(Tool::BumpStage0);
107 builder.run(&mut cmd);
111 #[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]
112 pub struct ReplaceVersionPlaceholder;
114 impl Step for ReplaceVersionPlaceholder {
116 const ONLY_HOSTS: bool = true;
118 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
119 run.path("src/tools/replace-version-placeholder")
122 fn make_run(run: RunConfig<'_>) {
123 run.builder.ensure(ReplaceVersionPlaceholder);
126 fn run(self, builder: &Builder<'_>) -> Self::Output {
127 let mut cmd = builder.tool_cmd(Tool::ReplaceVersionPlaceholder);
128 cmd.arg(&builder.src);
129 builder.run(&mut cmd);
133 #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
136 host: TargetSelection,
137 target: TargetSelection,
142 const ONLY_HOSTS: bool = false;
144 fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
145 run.path("src/tools/miri")
148 fn make_run(run: RunConfig<'_>) {
149 run.builder.ensure(Miri {
150 stage: run.builder.top_stage,
151 host: run.build_triple(),
156 fn run(self, builder: &Builder<'_>) {
157 let stage = self.stage;
158 let host = self.host;
159 let target = self.target;
160 let compiler = builder.compiler(stage, host);
163 .ensure(tool::Miri { compiler, target: self.host, extra_features: Vec::new() })
164 .expect("in-tree tool");
165 let miri_sysroot = test::Miri::build_miri_sysroot(builder, compiler, &miri, target);
168 // Running it via `cargo run` as that figures out the right dylib path.
169 // add_rustc_lib_path does not add the path that contains librustc_driver-<...>.so.
170 let mut miri = tool::prepare_tool_cargo(
180 miri.add_rustc_lib_path(builder, compiler);
181 // Forward arguments.
182 miri.arg("--").arg("--target").arg(target.rustc_target_arg());
183 miri.args(builder.config.cmd.args());
185 // miri tests need to know about the stage sysroot
186 miri.env("MIRI_SYSROOT", &miri_sysroot);
188 let mut miri = Command::from(miri);
189 builder.run(&mut miri);