@@ -20,11 +20,22 @@ pub struct Std {
20
20
///
21
21
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
22
22
crates : Vec < String > ,
23
+ /// Whether to force `Kind::Check` on cargo invocations.
24
+ ///
25
+ /// By default, `Builder::kind` is propagated to the cargo invocations. However, there are cases
26
+ /// when this is not desirable. For example, when running `x clippy $tool_name`, passing `Builder::kind`
27
+ /// to cargo invocations would run clippy on the entire compiler and library, which is not useful if
28
+ /// we only want to lint a few crates with specific rules.
29
+ force_check : bool ,
23
30
}
24
31
25
32
impl Std {
26
33
pub fn new ( target : TargetSelection ) -> Self {
27
- Self { target, crates : vec ! [ ] }
34
+ Self { target, crates : vec ! [ ] , force_check : false }
35
+ }
36
+
37
+ pub fn new_with_force_check_flag ( target : TargetSelection , force_check : bool ) -> Self {
38
+ Self { target, crates : vec ! [ ] , force_check }
28
39
}
29
40
}
30
41
@@ -38,7 +49,7 @@ impl Step for Std {
38
49
39
50
fn make_run ( run : RunConfig < ' _ > ) {
40
51
let crates = run. make_run_crates ( Alias :: Library ) ;
41
- run. builder . ensure ( Std { target : run. target , crates } ) ;
52
+ run. builder . ensure ( Std { target : run. target , crates, force_check : false } ) ;
42
53
}
43
54
44
55
fn run ( self , builder : & Builder < ' _ > ) {
@@ -53,7 +64,7 @@ impl Step for Std {
53
64
Mode :: Std ,
54
65
SourceType :: InTree ,
55
66
target,
56
- builder. kind ,
67
+ if self . force_check { Kind :: Check } else { builder. kind } ,
57
68
) ;
58
69
59
70
std_cargo ( builder, target, compiler. stage , & mut cargo) ;
@@ -148,6 +159,13 @@ pub struct Rustc {
148
159
///
149
160
/// [`compile::Rustc`]: crate::core::build_steps::compile::Rustc
150
161
crates : Vec < String > ,
162
+ /// Whether to force `Kind::Check` on cargo invocations.
163
+ ///
164
+ /// By default, `Builder::kind` is propagated to the cargo invocations. However, there are cases
165
+ /// when this is not desirable. For example, when running `x clippy $tool_name`, passing `Builder::kind`
166
+ /// to cargo invocations would run clippy on the entire compiler and library, which is not useful if
167
+ /// we only want to lint a few crates with specific rules.
168
+ force_check : bool ,
151
169
}
152
170
153
171
impl Rustc {
@@ -157,7 +175,20 @@ impl Rustc {
157
175
. into_iter ( )
158
176
. map ( |krate| krate. name . to_string ( ) )
159
177
. collect ( ) ;
160
- Self { target, crates }
178
+ Self { target, crates, force_check : false }
179
+ }
180
+
181
+ pub fn new_with_force_check_flag (
182
+ target : TargetSelection ,
183
+ builder : & Builder < ' _ > ,
184
+ force_check : bool ,
185
+ ) -> Self {
186
+ let crates = builder
187
+ . in_tree_crates ( "rustc-main" , Some ( target) )
188
+ . into_iter ( )
189
+ . map ( |krate| krate. name . to_string ( ) )
190
+ . collect ( ) ;
191
+ Self { target, crates, force_check }
161
192
}
162
193
}
163
194
@@ -172,7 +203,7 @@ impl Step for Rustc {
172
203
173
204
fn make_run ( run : RunConfig < ' _ > ) {
174
205
let crates = run. make_run_crates ( Alias :: Compiler ) ;
175
- run. builder . ensure ( Rustc { target : run. target , crates } ) ;
206
+ run. builder . ensure ( Rustc { target : run. target , crates, force_check : false } ) ;
176
207
}
177
208
178
209
/// Builds the compiler.
@@ -193,7 +224,7 @@ impl Step for Rustc {
193
224
builder. ensure ( crate :: core:: build_steps:: compile:: Std :: new ( compiler, compiler. host ) ) ;
194
225
builder. ensure ( crate :: core:: build_steps:: compile:: Std :: new ( compiler, target) ) ;
195
226
} else {
196
- builder. ensure ( Std :: new ( target) ) ;
227
+ builder. ensure ( Std :: new_with_force_check_flag ( target, self . force_check ) ) ;
197
228
}
198
229
199
230
let mut cargo = builder:: Cargo :: new (
@@ -202,7 +233,7 @@ impl Step for Rustc {
202
233
Mode :: Rustc ,
203
234
SourceType :: InTree ,
204
235
target,
205
- builder. kind ,
236
+ if self . force_check { Kind :: Check } else { builder. kind } ,
206
237
) ;
207
238
208
239
rustc_cargo ( builder, & mut cargo, target, & compiler) ;
0 commit comments