@@ -95,7 +95,7 @@ pub struct RunConfig<'a> {
95
95
pub builder : & ' a Builder < ' a > ,
96
96
pub host : Interned < String > ,
97
97
pub target : Interned < String > ,
98
- pub path : Option < & ' a Path > ,
98
+ pub path : & ' a Path ,
99
99
}
100
100
101
101
struct StepDescription {
@@ -105,6 +105,28 @@ struct StepDescription {
105
105
only_build : bool ,
106
106
should_run : fn ( ShouldRun ) -> ShouldRun ,
107
107
make_run : fn ( RunConfig ) ,
108
+ name : & ' static str ,
109
+ }
110
+
111
+ #[ derive( Debug , Clone , PartialOrd , Ord , PartialEq , Eq ) ]
112
+ struct PathSet {
113
+ set : BTreeSet < PathBuf > ,
114
+ }
115
+
116
+ impl PathSet {
117
+ fn one < P : Into < PathBuf > > ( path : P ) -> PathSet {
118
+ let mut set = BTreeSet :: new ( ) ;
119
+ set. insert ( path. into ( ) ) ;
120
+ PathSet { set }
121
+ }
122
+
123
+ fn has ( & self , needle : & Path ) -> bool {
124
+ self . set . iter ( ) . any ( |p| p. ends_with ( needle) )
125
+ }
126
+
127
+ fn path ( & self ) -> & Path {
128
+ self . set . iter ( ) . next ( ) . unwrap ( )
129
+ }
108
130
}
109
131
110
132
impl StepDescription {
@@ -116,30 +138,17 @@ impl StepDescription {
116
138
only_build : S :: ONLY_BUILD ,
117
139
should_run : S :: should_run,
118
140
make_run : S :: make_run,
141
+ name : unsafe { :: std:: intrinsics:: type_name :: < S > ( ) } ,
119
142
}
120
143
}
121
144
122
- fn maybe_run ( & self , builder : & Builder , should_run : & ShouldRun , path : Option < & Path > ) {
123
- if let Some ( path) = path {
124
- if builder. config . exclude . iter ( ) . any ( |e| e == path) {
125
- eprintln ! ( "Skipping {:?} because this path is excluded" , path) ;
126
- return ;
127
- } else if !builder. config . exclude . is_empty ( ) {
128
- eprintln ! ( "{:?} not skipped -- not in {:?}" , path, builder. config. exclude) ;
129
- }
130
- } else {
131
- if !should_run. paths . is_empty ( ) {
132
- if should_run. paths . iter ( ) . all ( |p| builder. config . exclude . contains ( & p) ) {
133
- eprintln ! ( "Skipping because all of its paths ({:?}) are excluded" ,
134
- should_run. paths) ;
135
- return ;
136
- } else if should_run. paths . len ( ) > 1 {
137
- for path in & should_run. paths {
138
- self . maybe_run ( builder, should_run, Some ( path) ) ;
139
- }
140
- return ;
141
- }
142
- }
145
+ fn maybe_run ( & self , builder : & Builder , pathset : & PathSet ) {
146
+ if builder. config . exclude . iter ( ) . any ( |e| pathset. has ( e) ) {
147
+ eprintln ! ( "Skipping {:?} because it is excluded" , pathset) ;
148
+ return ;
149
+ } else if !builder. config . exclude . is_empty ( ) {
150
+ eprintln ! ( "{:?} not skipped for {:?} -- not in {:?}" , pathset,
151
+ self . name, builder. config. exclude) ;
143
152
}
144
153
let build = builder. build ;
145
154
let hosts = if self . only_build_targets || self . only_build {
@@ -165,7 +174,7 @@ impl StepDescription {
165
174
for target in targets {
166
175
let run = RunConfig {
167
176
builder,
168
- path,
177
+ path : pathset . path ( ) ,
169
178
host : * host,
170
179
target : * target,
171
180
} ;
@@ -178,19 +187,28 @@ impl StepDescription {
178
187
let should_runs = v. iter ( ) . map ( |desc| {
179
188
( desc. should_run ) ( ShouldRun :: new ( builder) )
180
189
} ) . collect :: < Vec < _ > > ( ) ;
190
+
191
+ // sanity checks on rules
192
+ for ( desc, should_run) in v. iter ( ) . zip ( & should_runs) {
193
+ assert ! ( !should_run. paths. is_empty( ) ,
194
+ "{:?} should have at least one pathset" , desc. name) ;
195
+ }
196
+
181
197
if paths. is_empty ( ) {
182
198
for ( desc, should_run) in v. iter ( ) . zip ( should_runs) {
183
199
if desc. default && should_run. is_really_default {
184
- desc. maybe_run ( builder, & should_run, None ) ;
200
+ for pathset in & should_run. paths {
201
+ desc. maybe_run ( builder, pathset) ;
202
+ }
185
203
}
186
204
}
187
205
} else {
188
206
for path in paths {
189
207
let mut attempted_run = false ;
190
208
for ( desc, should_run) in v. iter ( ) . zip ( & should_runs) {
191
- if should_run. run ( path) {
209
+ if let Some ( pathset ) = should_run. pathset_for_path ( path) {
192
210
attempted_run = true ;
193
- desc. maybe_run ( builder, & should_run , Some ( path ) ) ;
211
+ desc. maybe_run ( builder, pathset ) ;
194
212
}
195
213
}
196
214
@@ -206,7 +224,7 @@ impl StepDescription {
206
224
pub struct ShouldRun < ' a > {
207
225
pub builder : & ' a Builder < ' a > ,
208
226
// use a BTreeSet to maintain sort order
209
- paths : BTreeSet < PathBuf > ,
227
+ paths : BTreeSet < PathSet > ,
210
228
211
229
// If this is a default rule, this is an additional constraint placed on
212
230
// it's run. Generally something like compiler docs being enabled.
@@ -227,15 +245,35 @@ impl<'a> ShouldRun<'a> {
227
245
self
228
246
}
229
247
248
+ // Unlike `krate` this will create just one pathset. As such, it probably shouldn't actually
249
+ // ever be used, but as we transition to having all rules properly handle passing krate(...) by
250
+ // actually doing something different for every crate passed.
251
+ pub fn all_krates ( mut self , name : & str ) -> Self {
252
+ let mut set = BTreeSet :: new ( ) ;
253
+ for krate in self . builder . in_tree_crates ( name) {
254
+ set. insert ( PathBuf :: from ( & krate. path ) ) ;
255
+ }
256
+ self . paths . insert ( PathSet { set } ) ;
257
+ self
258
+ }
259
+
230
260
pub fn krate ( mut self , name : & str ) -> Self {
231
- for ( _ , krate_path ) in self . builder . crates ( name) {
232
- self . paths . insert ( t ! ( env :: current_dir ( ) ) . join ( krate_path ) ) ;
261
+ for krate in self . builder . in_tree_crates ( name) {
262
+ self . paths . insert ( PathSet :: one ( & krate . path ) ) ;
233
263
}
234
264
self
235
265
}
236
266
237
- pub fn path ( mut self , path : & str ) -> Self {
238
- self . paths . insert ( t ! ( env:: current_dir( ) ) . join ( path) ) ;
267
+ // single, non-aliased path
268
+ pub fn path ( self , path : & str ) -> Self {
269
+ self . paths ( & [ path] )
270
+ }
271
+
272
+ // multiple aliases for the same job
273
+ pub fn paths ( mut self , paths : & [ & str ] ) -> Self {
274
+ self . paths . insert ( PathSet {
275
+ set : paths. iter ( ) . map ( PathBuf :: from) . collect ( ) ,
276
+ } ) ;
239
277
self
240
278
}
241
279
@@ -244,8 +282,8 @@ impl<'a> ShouldRun<'a> {
244
282
self
245
283
}
246
284
247
- fn run ( & self , path : & Path ) -> bool {
248
- self . paths . iter ( ) . any ( |p| path . ends_with ( p ) )
285
+ fn pathset_for_path ( & self , path : & Path ) -> Option < & PathSet > {
286
+ self . paths . iter ( ) . find ( |pathset| pathset . has ( path ) )
249
287
}
250
288
}
251
289
@@ -275,11 +313,16 @@ impl<'a> Builder<'a> {
275
313
tool:: RustInstaller , tool:: Cargo , tool:: Rls , tool:: Rustdoc , tool:: Clippy ,
276
314
native:: Llvm , tool:: Rustfmt , tool:: Miri ) ,
277
315
Kind :: Check => describe ! ( check:: Std , check:: Test , check:: Rustc ) ,
278
- Kind :: Test => describe ! ( test:: Tidy , test:: Bootstrap , test:: DefaultCompiletest ,
279
- test:: HostCompiletest , test:: Crate , test:: CrateLibrustc , test:: Rustdoc ,
280
- test:: Linkcheck , test:: Cargotest , test:: Cargo , test:: Rls , test:: Docs ,
281
- test:: ErrorIndex , test:: Distcheck , test:: Rustfmt , test:: Miri , test:: Clippy ,
282
- test:: RustdocJS , test:: RustdocTheme ) ,
316
+ Kind :: Test => describe ! ( test:: Tidy , test:: Bootstrap , test:: Ui , test:: RunPass ,
317
+ test:: CompileFail , test:: ParseFail , test:: RunFail , test:: RunPassValgrind ,
318
+ test:: MirOpt , test:: Codegen , test:: CodegenUnits , test:: Incremental , test:: Debuginfo ,
319
+ test:: UiFullDeps , test:: RunPassFullDeps , test:: RunFailFullDeps ,
320
+ test:: CompileFailFullDeps , test:: IncrementalFullDeps , test:: Rustdoc , test:: Pretty ,
321
+ test:: RunPassPretty , test:: RunFailPretty , test:: RunPassValgrindPretty ,
322
+ test:: RunPassFullDepsPretty , test:: RunFailFullDepsPretty , test:: RunMake ,
323
+ test:: Crate , test:: CrateLibrustc , test:: Rustdoc , test:: Linkcheck , test:: Cargotest ,
324
+ test:: Cargo , test:: Rls , test:: Docs , test:: ErrorIndex , test:: Distcheck ,
325
+ test:: Rustfmt , test:: Miri , test:: Clippy , test:: RustdocJS , test:: RustdocTheme ) ,
283
326
Kind :: Bench => describe ! ( test:: Crate , test:: CrateLibrustc ) ,
284
327
Kind :: Doc => describe ! ( doc:: UnstableBook , doc:: UnstableBookGen , doc:: TheBook ,
285
328
doc:: Standalone , doc:: Std , doc:: Test , doc:: Rustc , doc:: ErrorIndex , doc:: Nomicon ,
@@ -317,8 +360,10 @@ impl<'a> Builder<'a> {
317
360
should_run = ( desc. should_run ) ( should_run) ;
318
361
}
319
362
let mut help = String :: from ( "Available paths:\n " ) ;
320
- for path in should_run. paths {
321
- help. push_str ( format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( ) ) ;
363
+ for pathset in should_run. paths {
364
+ for path in pathset. set {
365
+ help. push_str ( format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( ) ) ;
366
+ }
322
367
}
323
368
Some ( help)
324
369
}
0 commit comments