@@ -70,17 +70,6 @@ pub(crate) trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash {
70
70
71
71
fn info ( _step_info : & mut StepInfo < ' _ , ' _ , Self > ) ;
72
72
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
-
84
73
/// Primary function to execute this rule. Can call `builder.ensure()`
85
74
/// with other steps to run those.
86
75
fn run ( self , builder : & Builder < ' _ > ) -> Self :: Output ;
@@ -1752,6 +1741,7 @@ pub(crate) struct StepInfo<'a, 'b, S> {
1752
1741
host : Option < TargetSelection > ,
1753
1742
target : Option < TargetSelection > ,
1754
1743
cmd : Option < Kind > ,
1744
+ path : Option < PathBuf > ,
1755
1745
}
1756
1746
1757
1747
impl < ' a > From < Compiler > for Cow < ' a , Compiler > {
@@ -1768,7 +1758,16 @@ impl<'a> From<&'a Compiler> for Cow<'a, Compiler> {
1768
1758
1769
1759
impl < ' a , ' b , S > StepInfo < ' a , ' b , S > {
1770
1760
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
+ }
1772
1771
}
1773
1772
1774
1773
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> {
1813
1812
self
1814
1813
}
1815
1814
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
+
1816
1823
/// Print a command that will run the current step.
1817
1824
///
1818
1825
/// This serves two purposes:
@@ -1822,33 +1829,31 @@ impl<'a, 'b, S> StepInfo<'a, 'b, S> {
1822
1829
where
1823
1830
S : Step ,
1824
1831
{
1825
- if self . builder . config . dry_run {
1832
+ let builder = self . builder ;
1833
+ if builder. config . dry_run {
1826
1834
return ;
1827
1835
}
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, ) ;
1838
1843
if let Some ( host) = self . host {
1839
1844
// 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 {
1841
1846
print ! ( " --host {}" , host) ;
1842
1847
}
1843
1848
}
1844
1849
if let Some ( target) = self . target {
1845
1850
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 {
1847
1852
print ! ( " --target {}" , target) ;
1848
1853
}
1849
1854
}
1850
1855
if kind == Kind :: Test {
1851
- for arg in self . builder . config . cmd . test_args ( ) {
1856
+ for arg in builder. config . cmd . test_args ( ) {
1852
1857
print ! ( " --test-args \" {}\" " , arg) ;
1853
1858
}
1854
1859
}
0 commit comments