Skip to content

Commit 1afeeef

Browse files
committed
Move most of the Step::run impl out of tool_check_step!
Ordinary code is much easier to work with than macro-generated code.
1 parent 7f75bfa commit 1afeeef

File tree

1 file changed

+41
-45
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+41
-45
lines changed

src/bootstrap/src/core/build_steps/check.rs

+41-45
Original file line numberDiff line numberDiff line change
@@ -428,53 +428,49 @@ macro_rules! tool_check_step {
428428
}
429429

430430
fn run(self, builder: &Builder<'_>) {
431-
let compiler = builder.compiler(builder.top_stage, builder.config.build);
432-
let target = self.target;
433-
434-
builder.ensure(Rustc::new(target, builder));
435-
436-
let mut cargo = prepare_tool_cargo(
437-
builder,
438-
compiler,
439-
Mode::ToolRustc,
440-
target,
441-
builder.kind,
442-
$path,
443-
$source_type,
444-
&[],
445-
);
446-
447-
// For ./x.py clippy, don't run with --all-targets because
448-
// linting tests and benchmarks can produce very noisy results
449-
if builder.kind != Kind::Clippy {
450-
cargo.arg("--all-targets");
451-
}
452-
453-
let _guard = builder.msg_check(&format!("{} artifacts", $display_name), target);
454-
run_cargo(
455-
builder,
456-
cargo,
457-
builder.config.free_args.clone(),
458-
&stamp(builder, compiler, target),
459-
vec![],
460-
true,
461-
false,
462-
);
463-
464-
/// Cargo's output path in a given stage, compiled by a particular
465-
/// compiler for the specified target.
466-
fn stamp(
467-
builder: &Builder<'_>,
468-
compiler: Compiler,
469-
target: TargetSelection,
470-
) -> PathBuf {
471-
builder
472-
.cargo_out(compiler, Mode::ToolRustc, target)
473-
.join(format!(".{}-check.stamp", stringify!($name).to_lowercase()))
474-
}
431+
let Self { target } = self;
432+
run_tool_check_step(builder, target, stringify!($name), $display_name, $path, $source_type);
475433
}
476434
}
477-
};
435+
}
436+
}
437+
438+
/// Used by the implementation of `Step::run` in `tool_check_step!`.
439+
fn run_tool_check_step(
440+
builder: &Builder<'_>,
441+
target: TargetSelection,
442+
step_type_name: &str,
443+
display_name: &str,
444+
path: &str,
445+
source_type: SourceType,
446+
) {
447+
let compiler = builder.compiler(builder.top_stage, builder.config.build);
448+
449+
builder.ensure(Rustc::new(target, builder));
450+
451+
let mut cargo = prepare_tool_cargo(
452+
builder,
453+
compiler,
454+
Mode::ToolRustc,
455+
target,
456+
builder.kind,
457+
path,
458+
source_type,
459+
&[],
460+
);
461+
462+
// For ./x.py clippy, don't run with --all-targets because
463+
// linting tests and benchmarks can produce very noisy results
464+
if builder.kind != Kind::Clippy {
465+
cargo.arg("--all-targets");
466+
}
467+
468+
let stamp = builder
469+
.cargo_out(compiler, Mode::ToolRustc, target)
470+
.join(format!(".{}-check.stamp", step_type_name.to_lowercase()));
471+
472+
let _guard = builder.msg_check(format!("{display_name} artifacts"), target);
473+
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
478474
}
479475

480476
tool_check_step!(Rustdoc, "rustdoc", "src/tools/rustdoc", "src/librustdoc", SourceType::InTree);

0 commit comments

Comments
 (0)