@@ -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 : PathBuf ,
99
99
}
100
100
101
101
struct StepDescription {
@@ -105,6 +105,32 @@ 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 empty ( ) -> PathSet {
118
+ PathSet { set : BTreeSet :: new ( ) }
119
+ }
120
+
121
+ fn one < P : Into < PathBuf > > ( path : P ) -> PathSet {
122
+ let mut set = BTreeSet :: new ( ) ;
123
+ set. insert ( path. into ( ) ) ;
124
+ PathSet { set }
125
+ }
126
+
127
+ fn has ( & self , needle : & Path ) -> bool {
128
+ self . set . iter ( ) . any ( |p| p. ends_with ( needle) )
129
+ }
130
+
131
+ fn path ( & self , builder : & Builder ) -> PathBuf {
132
+ self . set . iter ( ) . next ( ) . unwrap_or ( & builder. build . src ) . to_path_buf ( )
133
+ }
108
134
}
109
135
110
136
impl StepDescription {
@@ -116,10 +142,18 @@ impl StepDescription {
116
142
only_build : S :: ONLY_BUILD ,
117
143
should_run : S :: should_run,
118
144
make_run : S :: make_run,
145
+ name : unsafe { :: std:: intrinsics:: type_name :: < S > ( ) } ,
119
146
}
120
147
}
121
148
122
- fn maybe_run ( & self , builder : & Builder , path : Option < & Path > ) {
149
+ fn maybe_run ( & self , builder : & Builder , pathset : & PathSet ) {
150
+ if builder. config . exclude . iter ( ) . any ( |e| pathset. has ( e) ) {
151
+ eprintln ! ( "Skipping {:?} because it is excluded" , pathset) ;
152
+ return ;
153
+ } else if !builder. config . exclude . is_empty ( ) {
154
+ eprintln ! ( "{:?} not skipped for {:?} -- not in {:?}" , pathset,
155
+ self . name, builder. config. exclude) ;
156
+ }
123
157
let build = builder. build ;
124
158
let hosts = if self . only_build_targets || self . only_build {
125
159
build. build_triple ( )
@@ -144,7 +178,7 @@ impl StepDescription {
144
178
for target in targets {
145
179
let run = RunConfig {
146
180
builder,
147
- path,
181
+ path : pathset . path ( builder ) ,
148
182
host : * host,
149
183
target : * target,
150
184
} ;
@@ -157,19 +191,28 @@ impl StepDescription {
157
191
let should_runs = v. iter ( ) . map ( |desc| {
158
192
( desc. should_run ) ( ShouldRun :: new ( builder) )
159
193
} ) . collect :: < Vec < _ > > ( ) ;
194
+
195
+ // sanity checks on rules
196
+ for ( desc, should_run) in v. iter ( ) . zip ( & should_runs) {
197
+ assert ! ( !should_run. paths. is_empty( ) ,
198
+ "{:?} should have at least one pathset" , desc. name) ;
199
+ }
200
+
160
201
if paths. is_empty ( ) {
161
202
for ( desc, should_run) in v. iter ( ) . zip ( should_runs) {
162
203
if desc. default && should_run. is_really_default {
163
- desc. maybe_run ( builder, None ) ;
204
+ for pathset in & should_run. paths {
205
+ desc. maybe_run ( builder, pathset) ;
206
+ }
164
207
}
165
208
}
166
209
} else {
167
210
for path in paths {
168
211
let mut attempted_run = false ;
169
212
for ( desc, should_run) in v. iter ( ) . zip ( & should_runs) {
170
- if should_run. run ( path) {
213
+ if let Some ( pathset ) = should_run. pathset_for_path ( path) {
171
214
attempted_run = true ;
172
- desc. maybe_run ( builder, Some ( path ) ) ;
215
+ desc. maybe_run ( builder, pathset ) ;
173
216
}
174
217
}
175
218
@@ -185,7 +228,7 @@ impl StepDescription {
185
228
pub struct ShouldRun < ' a > {
186
229
pub builder : & ' a Builder < ' a > ,
187
230
// use a BTreeSet to maintain sort order
188
- paths : BTreeSet < PathBuf > ,
231
+ paths : BTreeSet < PathSet > ,
189
232
190
233
// If this is a default rule, this is an additional constraint placed on
191
234
// it's run. Generally something like compiler docs being enabled.
@@ -206,25 +249,46 @@ impl<'a> ShouldRun<'a> {
206
249
self
207
250
}
208
251
252
+ // Unlike `krate` this will create just one pathset. As such, it probably shouldn't actually
253
+ // ever be used, but as we transition to having all rules properly handle passing krate(...) by
254
+ // actually doing something different for every crate passed.
255
+ pub fn all_krates ( mut self , name : & str ) -> Self {
256
+ let mut set = BTreeSet :: new ( ) ;
257
+ for krate in self . builder . in_tree_crates ( name) {
258
+ set. insert ( PathBuf :: from ( & krate. path ) ) ;
259
+ }
260
+ self . paths . insert ( PathSet { set } ) ;
261
+ self
262
+ }
263
+
209
264
pub fn krate ( mut self , name : & str ) -> Self {
210
- for ( _ , krate_path ) in self . builder . crates ( name) {
211
- self . paths . insert ( PathBuf :: from ( krate_path ) ) ;
265
+ for krate in self . builder . in_tree_crates ( name) {
266
+ self . paths . insert ( PathSet :: one ( & krate . path ) ) ;
212
267
}
213
268
self
214
269
}
215
270
216
- pub fn path ( mut self , path : & str ) -> Self {
217
- self . paths . insert ( PathBuf :: from ( path) ) ;
271
+ // single, non-aliased path
272
+ pub fn path ( self , path : & str ) -> Self {
273
+ self . paths ( & [ path] )
274
+ }
275
+
276
+ // multiple aliases for the same job
277
+ pub fn paths ( mut self , paths : & [ & str ] ) -> Self {
278
+ self . paths . insert ( PathSet {
279
+ set : paths. iter ( ) . map ( PathBuf :: from) . collect ( ) ,
280
+ } ) ;
218
281
self
219
282
}
220
283
221
284
// allows being more explicit about why should_run in Step returns the value passed to it
222
- pub fn never ( self ) -> ShouldRun < ' a > {
285
+ pub fn never ( mut self ) -> ShouldRun < ' a > {
286
+ self . paths . insert ( PathSet :: empty ( ) ) ;
223
287
self
224
288
}
225
289
226
- fn run ( & self , path : & Path ) -> bool {
227
- self . paths . iter ( ) . any ( |p| path . ends_with ( p ) )
290
+ fn pathset_for_path ( & self , path : & Path ) -> Option < & PathSet > {
291
+ self . paths . iter ( ) . find ( |pathset| pathset . has ( path ) )
228
292
}
229
293
}
230
294
@@ -254,19 +318,23 @@ impl<'a> Builder<'a> {
254
318
tool:: RustInstaller , tool:: Cargo , tool:: Rls , tool:: Rustdoc , tool:: Clippy ,
255
319
native:: Llvm , tool:: Rustfmt , tool:: Miri ) ,
256
320
Kind :: Check => describe ! ( check:: Std , check:: Test , check:: Rustc ) ,
257
- Kind :: Test => describe ! ( test:: Tidy , test:: Bootstrap , test:: DefaultCompiletest ,
258
- test:: HostCompiletest , test:: Crate , test:: CrateLibrustc , test:: Rustdoc ,
259
- test:: Linkcheck , test:: Cargotest , test:: Cargo , test:: Rls , test:: Docs ,
260
- test:: ErrorIndex , test:: Distcheck , test:: Rustfmt , test:: Miri , test:: Clippy ,
261
- test:: RustdocJS , test:: RustdocTheme ) ,
321
+ Kind :: Test => describe ! ( test:: Tidy , test:: Bootstrap , test:: Ui , test:: RunPass ,
322
+ test:: CompileFail , test:: ParseFail , test:: RunFail , test:: RunPassValgrind ,
323
+ test:: MirOpt , test:: Codegen , test:: CodegenUnits , test:: Incremental , test:: Debuginfo ,
324
+ test:: UiFullDeps , test:: RunPassFullDeps , test:: RunFailFullDeps ,
325
+ test:: CompileFailFullDeps , test:: IncrementalFullDeps , test:: Rustdoc , test:: Pretty ,
326
+ test:: RunPassPretty , test:: RunFailPretty , test:: RunPassValgrindPretty ,
327
+ test:: RunPassFullDepsPretty , test:: RunFailFullDepsPretty , test:: RunMake ,
328
+ test:: Crate , test:: CrateLibrustc , test:: Rustdoc , test:: Linkcheck , test:: Cargotest ,
329
+ test:: Cargo , test:: Rls , test:: Docs , test:: ErrorIndex , test:: Distcheck ,
330
+ test:: Rustfmt , test:: Miri , test:: Clippy , test:: RustdocJS , test:: RustdocTheme ) ,
262
331
Kind :: Bench => describe ! ( test:: Crate , test:: CrateLibrustc ) ,
263
332
Kind :: Doc => describe ! ( doc:: UnstableBook , doc:: UnstableBookGen , doc:: TheBook ,
264
333
doc:: Standalone , doc:: Std , doc:: Test , doc:: Rustc , doc:: ErrorIndex , doc:: Nomicon ,
265
334
doc:: Reference , doc:: Rustdoc , doc:: RustByExample , doc:: CargoBook ) ,
266
335
Kind :: Dist => describe ! ( dist:: Docs , dist:: Mingw , dist:: Rustc , dist:: DebuggerScripts ,
267
336
dist:: Std , dist:: Analysis , dist:: Src , dist:: PlainSourceTarball , dist:: Cargo ,
268
- dist:: Rls , dist:: Rustfmt , dist:: Extended , dist:: HashSign ,
269
- dist:: DontDistWithMiriEnabled ) ,
337
+ dist:: Rls , dist:: Rustfmt , dist:: Extended , dist:: HashSign ) ,
270
338
Kind :: Install => describe ! ( install:: Docs , install:: Std , install:: Cargo , install:: Rls ,
271
339
install:: Rustfmt , install:: Analysis , install:: Src , install:: Rustc ) ,
272
340
}
@@ -297,8 +365,10 @@ impl<'a> Builder<'a> {
297
365
should_run = ( desc. should_run ) ( should_run) ;
298
366
}
299
367
let mut help = String :: from ( "Available paths:\n " ) ;
300
- for path in should_run. paths {
301
- help. push_str ( format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( ) ) ;
368
+ for pathset in should_run. paths {
369
+ for path in pathset. set {
370
+ help. push_str ( format ! ( " ./x.py {} {}\n " , subcommand, path. display( ) ) . as_str ( ) ) ;
371
+ }
302
372
}
303
373
Some ( help)
304
374
}
@@ -323,6 +393,12 @@ impl<'a> Builder<'a> {
323
393
stack : RefCell :: new ( Vec :: new ( ) ) ,
324
394
} ;
325
395
396
+ if kind == Kind :: Dist {
397
+ assert ! ( !build. config. test_miri, "Do not distribute with miri enabled.\n \
398
+ The distributed libraries would include all MIR (increasing binary size).
399
+ The distributed MIR would include validation statements." ) ;
400
+ }
401
+
326
402
StepDescription :: run ( & Builder :: get_step_descriptions ( builder. kind ) , & builder, paths) ;
327
403
}
328
404
0 commit comments