@@ -112,83 +112,89 @@ impl Step for Rustc {
112
112
}
113
113
}
114
114
115
- #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
116
- pub struct Rustdoc {
117
- pub target : Interned < String > ,
115
+ macro_rules! tool_check_step {
116
+ ( $name: ident, $path: expr) => {
117
+ #[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash ) ]
118
+ pub struct $name {
119
+ pub target: Interned <String >,
120
+ }
121
+
122
+ impl Step for $name {
123
+ type Output = ( ) ;
124
+ const ONLY_HOSTS : bool = true ;
125
+ const DEFAULT : bool = true ;
126
+
127
+ fn should_run( run: ShouldRun <' _>) -> ShouldRun <' _> {
128
+ run. path( $path)
129
+ }
130
+
131
+ fn make_run( run: RunConfig <' _>) {
132
+ run. builder. ensure( $name { target: run. target } ) ;
133
+ }
134
+
135
+ fn run( self , builder: & Builder <' _>) {
136
+ let compiler = builder. compiler( 0 , builder. config. build) ;
137
+ let target = self . target;
138
+
139
+ builder. ensure( Rustc { target } ) ;
140
+
141
+ let cargo = prepare_tool_cargo(
142
+ builder,
143
+ compiler,
144
+ Mode :: ToolRustc ,
145
+ target,
146
+ cargo_subcommand( builder. kind) ,
147
+ $path,
148
+ SourceType :: InTree ,
149
+ & [ ] ,
150
+ ) ;
151
+
152
+ println!(
153
+ "Checking {} artifacts ({} -> {})" ,
154
+ stringify!( $name) . to_lowercase( ) ,
155
+ & compiler. host,
156
+ target
157
+ ) ;
158
+ run_cargo(
159
+ builder,
160
+ cargo,
161
+ args( builder. kind) ,
162
+ & stamp( builder, compiler, target) ,
163
+ vec![ ] ,
164
+ true ,
165
+ ) ;
166
+
167
+ let libdir = builder. sysroot_libdir( compiler, target) ;
168
+ let hostdir = builder. sysroot_libdir( compiler, compiler. host) ;
169
+ add_to_sysroot( & builder, & libdir, & hostdir, & stamp( builder, compiler, target) ) ;
170
+
171
+ /// Cargo's output path in a given stage, compiled by a particular
172
+ /// compiler for the specified target.
173
+ fn stamp(
174
+ builder: & Builder <' _>,
175
+ compiler: Compiler ,
176
+ target: Interned <String >,
177
+ ) -> PathBuf {
178
+ builder
179
+ . cargo_out( compiler, Mode :: ToolRustc , target)
180
+ . join( format!( ".{}-check.stamp" , stringify!( $name) . to_lowercase( ) ) )
181
+ }
182
+ }
183
+ }
184
+ } ;
118
185
}
119
186
120
- impl Step for Rustdoc {
121
- type Output = ( ) ;
122
- const ONLY_HOSTS : bool = true ;
123
- const DEFAULT : bool = true ;
124
-
125
- fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
126
- run. path ( "src/tools/rustdoc" )
127
- }
128
-
129
- fn make_run ( run : RunConfig < ' _ > ) {
130
- run. builder . ensure ( Rustdoc { target : run. target } ) ;
131
- }
132
-
133
- fn run ( self , builder : & Builder < ' _ > ) {
134
- let compiler = builder. compiler ( 0 , builder. config . build ) ;
135
- let target = self . target ;
136
-
137
- builder. ensure ( Rustc { target } ) ;
138
-
139
- let cargo = prepare_tool_cargo (
140
- builder,
141
- compiler,
142
- Mode :: ToolRustc ,
143
- target,
144
- cargo_subcommand ( builder. kind ) ,
145
- "src/tools/rustdoc" ,
146
- SourceType :: InTree ,
147
- & [ ] ,
148
- ) ;
149
-
150
- println ! ( "Checking rustdoc artifacts ({} -> {})" , & compiler. host, target) ;
151
- run_cargo (
152
- builder,
153
- cargo,
154
- args ( builder. kind ) ,
155
- & rustdoc_stamp ( builder, compiler, target) ,
156
- vec ! [ ] ,
157
- true ,
158
- ) ;
159
-
160
- let libdir = builder. sysroot_libdir ( compiler, target) ;
161
- let hostdir = builder. sysroot_libdir ( compiler, compiler. host ) ;
162
- add_to_sysroot ( & builder, & libdir, & hostdir, & rustdoc_stamp ( builder, compiler, target) ) ;
163
- }
164
- }
187
+ tool_check_step ! ( Rustdoc , "src/tools/rustdoc" ) ;
188
+ tool_check_step ! ( Clippy , "src/tools/clippy" ) ;
165
189
166
190
/// Cargo's output path for the standard library in a given stage, compiled
167
191
/// by a particular compiler for the specified target.
168
- pub fn libstd_stamp (
169
- builder : & Builder < ' _ > ,
170
- compiler : Compiler ,
171
- target : Interned < String > ,
172
- ) -> PathBuf {
192
+ fn libstd_stamp ( builder : & Builder < ' _ > , compiler : Compiler , target : Interned < String > ) -> PathBuf {
173
193
builder. cargo_out ( compiler, Mode :: Std , target) . join ( ".libstd-check.stamp" )
174
194
}
175
195
176
196
/// Cargo's output path for librustc in a given stage, compiled by a particular
177
197
/// compiler for the specified target.
178
- pub fn librustc_stamp (
179
- builder : & Builder < ' _ > ,
180
- compiler : Compiler ,
181
- target : Interned < String > ,
182
- ) -> PathBuf {
198
+ fn librustc_stamp ( builder : & Builder < ' _ > , compiler : Compiler , target : Interned < String > ) -> PathBuf {
183
199
builder. cargo_out ( compiler, Mode :: Rustc , target) . join ( ".librustc-check.stamp" )
184
200
}
185
-
186
- /// Cargo's output path for rustdoc in a given stage, compiled by a particular
187
- /// compiler for the specified target.
188
- pub fn rustdoc_stamp (
189
- builder : & Builder < ' _ > ,
190
- compiler : Compiler ,
191
- target : Interned < String > ,
192
- ) -> PathBuf {
193
- builder. cargo_out ( compiler, Mode :: ToolRustc , target) . join ( ".rustdoc-check.stamp" )
194
- }
0 commit comments