@@ -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
17571747impl < ' a > From < Compiler > for Cow < ' a , Compiler > {
@@ -1768,7 +1758,16 @@ impl<'a> From<&'a Compiler> for Cow<'a, Compiler> {
17681758
17691759impl < ' 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 }
0 commit comments