Skip to content

Commit 95d4071

Browse files
committed
Use compiler() instead of stage()
1 parent 35b1673 commit 95d4071

File tree

4 files changed

+65
-12
lines changed

4 files changed

+65
-12
lines changed

src/bootstrap/builder.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,26 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
6767
std::any::type_name::<Self>()
6868
}
6969

70+
// fn kind(&self) -> Kind;
71+
72+
fn compiler(&self) -> Option<&Compiler> {
73+
None
74+
}
75+
76+
fn target(&self) -> Option<&TargetSelection> {
77+
None
78+
}
79+
7080
/// The path that should be used on the command line to run this step.
7181
fn path(&self, builder: &Builder<'_>) -> PathBuf {
7282
let paths = Self::should_run(ShouldRun::new(builder)).paths;
7383
paths.iter().map(|pathset| pathset.path(builder)).next().expect("no paths for step")
7484
}
7585

76-
/// The stage that should be passed to x.py to run this step.
77-
fn stage(&self, builder: &Builder<'_>) -> u32 {
78-
builder.top_stage
79-
}
86+
// /// The stage that should be passed to x.py to run this step.
87+
// fn stage(&self, builder: &Builder<'_>) -> u32 {
88+
// builder.top_stage
89+
// }
8090

8191
/// Primary function to execute this rule. Can call `builder.ensure()`
8292
/// with other steps to run those.
@@ -655,13 +665,24 @@ impl<'a> Builder<'a> {
655665
if self.config.dry_run {
656666
return;
657667
}
668+
let (stage, host) = if let Some(compiler) = step.compiler() {
669+
(compiler.stage, Some(compiler.host))
670+
} else {
671+
(self.top_stage, None)
672+
};
658673
print!(
659674
"{} {} --stage {}",
660675
// TODO: this is wrong, e.g. `check --stage 1` runs build commands first
661676
self.kind,
662677
step.path(self).display(),
663-
step.stage(self),
678+
stage,
664679
);
680+
if let Some(host) = host {
681+
print!(" --host {}", host);
682+
}
683+
if let Some(target) = step.target() {
684+
print!(" --target {}", target);
685+
}
665686
for arg in self.config.cmd.test_args() {
666687
print!(" --test-args \"{}\"", arg);
667688
}

src/bootstrap/compile.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ impl Step for Std {
5454
});
5555
}
5656

57+
fn compiler(&self) -> Option<&Compiler> {
58+
Some(&self.compiler)
59+
}
60+
61+
fn target(&self) -> Option<&TargetSelection> {
62+
Some(&self.target)
63+
}
64+
5765
/// Builds the standard library.
5866
///
5967
/// This will build the standard library for a particular stage of the build
@@ -519,10 +527,14 @@ impl Step for Rustc {
519527
});
520528
}
521529

522-
fn stage(&self, _builder: &Builder<'_>) -> u32 {
523-
self.compiler.stage
530+
fn compiler(&self) -> Option<&Compiler> {
531+
Some(&self.compiler)
524532
}
525533

534+
// fn stage(&self, _builder: &Builder<'_>) -> u32 {
535+
// self.compiler.stage
536+
// }
537+
526538
/// Builds the compiler.
527539
///
528540
/// This will build the compiler for a particular stage of the build using

src/bootstrap/tool.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,16 @@ macro_rules! bootstrap_tool {
319319
impl Step for $name {
320320
type Output = PathBuf;
321321

322-
fn stage(&self, _builder: &Builder<'_>) -> u32 {
323-
self.compiler.stage
322+
// fn stage(&self, _builder: &Builder<'_>) -> u32 {
323+
// self.compiler.stage
324+
// }
325+
326+
fn compiler(&self) -> Option<&Compiler> {
327+
Some(&self.compiler)
328+
}
329+
330+
fn target(&self) -> Option<&TargetSelection> {
331+
Some(&self.target)
324332
}
325333

326334
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -599,8 +607,16 @@ impl Step for Cargo {
599607
const DEFAULT: bool = true;
600608
const ONLY_HOSTS: bool = true;
601609

602-
fn stage(&self, _builder: &Builder<'_>) -> u32 {
603-
self.compiler.stage
610+
// fn stage(&self, _builder: &Builder<'_>) -> u32 {
611+
// self.compiler.stage
612+
// }
613+
614+
fn compiler(&self) -> Option<&Compiler> {
615+
Some(&self.compiler)
616+
}
617+
618+
fn target(&self) -> Option<&TargetSelection> {
619+
Some(&self.target)
604620
}
605621

606622
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

src/bootstrap/toolstate.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::builder::{Builder, RunConfig, ShouldRun, Step};
1+
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
22
use build_helper::t;
33
use serde::{Deserialize, Serialize};
44
use std::collections::HashMap;
@@ -141,6 +141,10 @@ pub struct ToolStateCheck;
141141
impl Step for ToolStateCheck {
142142
type Output = ();
143143

144+
// fn kind(&self) -> Kind {
145+
// Kind::Test
146+
// }
147+
144148
/// Checks tool state status.
145149
///
146150
/// This is intended to be used in the `checktools.sh` script. To use

0 commit comments

Comments
 (0)