Skip to content

Commit c47f73b

Browse files
committed
cleanup
1 parent a6f8a1d commit c47f73b

File tree

8 files changed

+59
-71
lines changed

8 files changed

+59
-71
lines changed

src/bootstrap/builder.rs

+31-26
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,6 @@ pub(crate) trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
7070

7171
fn info(_step_info: &mut StepInfo<'_, '_, Self>);
7272

73-
/// The path that should be used on the command line to run this step.
74-
fn path(&self, builder: &Builder<'_>) -> PathBuf {
75-
let paths = Self::should_run(ShouldRun::new(builder)).paths;
76-
paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step")
77-
}
78-
79-
// /// The stage that should be passed to x.py to run this step.
80-
// fn stage(&self, builder: &Builder<'_>) -> u32 {
81-
// builder.top_stage
82-
// }
83-
8473
/// Primary function to execute this rule. Can call `builder.ensure()`
8574
/// with other steps to run those.
8675
fn run(self, builder: &Builder<'_>) -> Self::Output;
@@ -1752,6 +1741,7 @@ pub(crate) struct StepInfo<'a, 'b, S> {
17521741
host: Option<TargetSelection>,
17531742
target: Option<TargetSelection>,
17541743
cmd: Option<Kind>,
1744+
path: Option<PathBuf>,
17551745
}
17561746

17571747
impl<'a> From<Compiler> for Cow<'a, Compiler> {
@@ -1768,7 +1758,16 @@ impl<'a> From<&'a Compiler> for Cow<'a, Compiler> {
17681758

17691759
impl<'a, 'b, S> StepInfo<'a, 'b, S> {
17701760
pub(crate) fn new(builder: &'a Builder<'b>, step: &'a S) -> Self {
1771-
Self { builder, step, compiler: None, stage: None, host: None, target: None, cmd: None }
1761+
Self {
1762+
builder,
1763+
step,
1764+
compiler: None,
1765+
stage: None,
1766+
host: None,
1767+
target: None,
1768+
cmd: None,
1769+
path: None,
1770+
}
17721771
}
17731772

17741773
pub(crate) fn compiler(&mut self, val: impl Into<Cow<'a, Compiler>>) -> &mut Self {
@@ -1813,6 +1812,14 @@ impl<'a, 'b, S> StepInfo<'a, 'b, S> {
18131812
self
18141813
}
18151814

1815+
pub(crate) fn path(&mut self, val: PathBuf) -> &mut Self {
1816+
if self.path.is_some() {
1817+
panic!("cannot overwrite path");
1818+
}
1819+
self.path = Some(val);
1820+
self
1821+
}
1822+
18161823
/// Print a command that will run the current step.
18171824
///
18181825
/// This serves two purposes:
@@ -1822,33 +1829,31 @@ impl<'a, 'b, S> StepInfo<'a, 'b, S> {
18221829
where
18231830
S: Step,
18241831
{
1825-
if self.builder.config.dry_run {
1832+
let builder = self.builder;
1833+
if builder.config.dry_run {
18261834
return;
18271835
}
1828-
// let stage = self.stage.unwrap_or(self.builder.top_stage);
1829-
let stage = self.stage.expect("missing stage");
1830-
// let kind = self.cmd.unwrap_or(self.builder.kind);
1831-
let kind = self.cmd.expect("missing kind");
1832-
print!(
1833-
"{} {} --stage {}",
1834-
kind,
1835-
self.step.path(self.builder).display(),
1836-
stage,
1837-
);
1836+
let stage = self.stage.unwrap_or(self.builder.top_stage);
1837+
let kind = self.cmd.unwrap_or_else(|| panic!("missing kind for {}", self.step.name()));
1838+
let path = self.path.clone().unwrap_or_else(|| {
1839+
let paths = S::should_run(ShouldRun::new(builder)).paths;
1840+
paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step")
1841+
});
1842+
print!("{} {} --stage {}", kind, path.display(), stage,);
18381843
if let Some(host) = self.host {
18391844
// Almost always, this will be the same as build. Don't print it if so.
1840-
if host != self.builder.config.build {
1845+
if host != builder.config.build {
18411846
print!(" --host {}", host);
18421847
}
18431848
}
18441849
if let Some(target) = self.target {
18451850
let different_from_host = self.host.map_or(false, |h| h != target);
1846-
if target != self.builder.config.build || different_from_host {
1851+
if target != builder.config.build || different_from_host {
18471852
print!(" --target {}", target);
18481853
}
18491854
}
18501855
if kind == Kind::Test {
1851-
for arg in self.builder.config.cmd.test_args() {
1856+
for arg in builder.config.cmd.test_args() {
18521857
print!(" --test-args \"{}\"", arg);
18531858
}
18541859
}

src/bootstrap/check.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ impl Step for Std {
9494
std_cargo(builder, target, compiler.stage, &mut cargo);
9595

9696
builder.step_info(&self);
97-
// builder.info(&format!(
98-
// "Checking stage{} std artifacts ({} -> {})",
99-
// builder.top_stage, &compiler.host, target
100-
// ));
10197
run_cargo(
10298
builder,
10399
cargo,
@@ -141,7 +137,7 @@ impl Step for Std {
141137
}
142138

143139
builder.info(&format!(
144-
"Checking stage{} std test/bench/example targets ({} -> {})",
140+
"check library/alloc --stage {} --all-targets --host {} --target {}",
145141
builder.top_stage, &compiler.host, target
146142
));
147143
run_cargo(
@@ -222,10 +218,6 @@ impl Step for Rustc {
222218
}
223219

224220
builder.step_info(&self);
225-
// builder.info(&format!(
226-
// "Checking stage{} compiler artifacts ({} -> {})",
227-
// builder.top_stage, &compiler.host, target
228-
// ));
229221
run_cargo(
230222
builder,
231223
cargo,
@@ -287,10 +279,6 @@ impl Step for CodegenBackend {
287279
rustc_cargo_env(builder, &mut cargo, target);
288280

289281
builder.step_info(&self);
290-
// builder.info(&format!(
291-
// "Checking stage{} {} artifacts ({} -> {})",
292-
// builder.top_stage, backend, &compiler.host.triple, target.triple
293-
// ));
294282

295283
run_cargo(
296284
builder,
@@ -358,13 +346,6 @@ macro_rules! tool_check_step {
358346
cargo.rustflag("-Zunstable-options");
359347

360348
builder.step_info(&self);
361-
// builder.info(&format!(
362-
// "Checking stage{} {} artifacts ({} -> {})",
363-
// builder.top_stage,
364-
// stringify!($name).to_lowercase(),
365-
// &compiler.host.triple,
366-
// target.triple
367-
// ));
368349
run_cargo(
369350
builder,
370351
cargo,

src/bootstrap/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ macro_rules! compiler_target_info {
5151
let step = step_info.step;
5252
step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Dist);
5353
}
54-
}
54+
};
5555
}
5656

5757
#[derive(Debug, PartialOrd, Ord, Copy, Clone, Hash, PartialEq, Eq)]

src/bootstrap/doc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ macro_rules! target_info {
3636
fn info(step_info: &mut StepInfo<'_, '_, Self>) {
3737
step_info.target(step_info.step.target).cmd(Kind::Doc);
3838
}
39-
}
39+
};
4040
}
4141

4242
macro_rules! compiler_target_info {
@@ -45,7 +45,7 @@ macro_rules! compiler_target_info {
4545
let step = step_info.step;
4646
step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Doc);
4747
}
48-
}
48+
};
4949
}
5050

5151
macro_rules! stage_target_info {
@@ -54,7 +54,7 @@ macro_rules! stage_target_info {
5454
let step = step_info.step;
5555
step_info.stage(step.stage).target(step.target).cmd(Kind::Doc);
5656
}
57-
}
57+
};
5858
}
5959

6060
macro_rules! book {
@@ -818,7 +818,7 @@ impl Step for UnstableBookGen {
818818
fn run(self, builder: &Builder<'_>) {
819819
let target = self.target;
820820

821-
builder.info(&format!("Generating unstable book md files ({})", target));
821+
builder.step_info(&self);
822822
let out = builder.md_doc_out(target).join("unstable-book");
823823
builder.create_dir(&out);
824824
builder.remove_dir(&out);

src/bootstrap/install.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ macro_rules! compiler_target_info {
9696
let step = step_info.step;
9797
step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Install);
9898
}
99-
}
99+
};
100100
}
101101

102102
macro_rules! install {

src/bootstrap/native.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! target_info {
2929
fn info(step_info: &mut StepInfo<'_, '_, Self>) {
3030
step_info.target(step_info.step.target).cmd(Kind::Build);
3131
}
32-
}
32+
};
3333
}
3434

3535
pub struct Meta {

src/bootstrap/test.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ macro_rules! host_info {
3232
let step = step_info.step;
3333
step_info.host(step.host).cmd(Kind::Test);
3434
}
35-
}
35+
};
3636
}
3737

3838
macro_rules! stage_host_info {
@@ -41,7 +41,7 @@ macro_rules! stage_host_info {
4141
let step = step_info.step;
4242
step_info.stage(step.stage).host(step.host).cmd(Kind::Test);
4343
}
44-
}
44+
};
4545
}
4646

4747
macro_rules! compiler_target_info {
@@ -50,7 +50,7 @@ macro_rules! compiler_target_info {
5050
let step = step_info.step;
5151
step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Test);
5252
}
53-
}
53+
};
5454
}
5555

5656
const ADB_TEST_DIR: &str = "/data/tmp/work";
@@ -1047,7 +1047,7 @@ impl Step for Tidy {
10471047
try_run(builder, &mut cmd);
10481048

10491049
if builder.config.channel == "dev" || builder.config.channel == "nightly" {
1050-
builder.info("fmt check");
1050+
builder.info("fmt --check");
10511051
if builder.config.initial_rustfmt.is_none() {
10521052
let inferred_rustfmt_dir = builder.config.initial_rustc.parent().unwrap();
10531053
eprintln!(
@@ -1291,11 +1291,14 @@ impl Step for Compiletest {
12911291
run.never()
12921292
}
12931293

1294-
compiler_target_info!();
1295-
1296-
fn path(&self, _builder: &Builder<'_>) -> PathBuf {
1294+
fn info(step_info: &mut StepInfo<'_, '_, Self>) {
1295+
let step = step_info.step;
12971296
// FIXME: it would be nice to suggest exactly the tests that fail, but that info isn't known without first running compiletest.
1298-
self.path.into()
1297+
step_info
1298+
.path(step.path.into())
1299+
.compiler(&step.compiler)
1300+
.target(step.target)
1301+
.cmd(Kind::Test);
12991302
}
13001303

13011304
/// Executes the `compiletest` tool to run a suite of tests.
@@ -1667,10 +1670,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
16671670

16681671
builder.ci_env.force_coloring_in_ci(&mut cmd);
16691672

1670-
builder.info(&format!(
1671-
"Check compiletest suite={} mode={} ({} -> {})",
1672-
suite, mode, &compiler.host, target
1673-
));
1673+
builder.step_info(&self);
16741674
let _time = util::timeit(&builder);
16751675
try_run(builder, &mut cmd);
16761676

@@ -1704,8 +1704,7 @@ impl Step for BookTest {
17041704

17051705
fn info(step_info: &mut StepInfo<'_, '_, Self>) {
17061706
let step = step_info.step;
1707-
todo!("path");
1708-
step_info.compiler(&step.compiler).cmd(Kind::Test);
1707+
step_info.path(step.path.clone()).compiler(&step.compiler).cmd(Kind::Test);
17091708
}
17101709

17111710
/// Runs the documentation tests for a book in `src/doc`.
@@ -2056,10 +2055,12 @@ impl Step for Crate {
20562055
}
20572056
}
20582057

2059-
compiler_target_info!();
2060-
2061-
fn path(&self, _builder: &Builder<'_>) -> PathBuf {
2062-
self.krate_path.file_name().expect("top-level directory is not a crate").into()
2058+
fn info(step_info: &mut StepInfo<'_, '_, Self>) {
2059+
let step = step_info.step;
2060+
// FIXME: it would be nice to suggest exactly the tests that fail, but that info isn't known without first running compiletest.
2061+
step_info
2062+
.path(step.krate_path.file_name().expect("top-level directory is not a crate").into());
2063+
step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Test);
20632064
}
20642065

20652066
/// Runs all unit tests plus documentation tests for a given crate defined

src/bootstrap/tool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl Step for ToolBuild {
4343
fn info(step_info: &mut StepInfo<'_, '_, Self>) {
4444
let step = step_info.step;
4545
// todo!("path");
46+
step_info.path(step.path.into());
4647
step_info.compiler(&step.compiler).target(step.target).cmd(Kind::Build);
4748
}
4849

0 commit comments

Comments
 (0)