@@ -403,71 +403,66 @@ impl Step for Cargo {
403
403
}
404
404
}
405
405
406
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
407
- pub struct Clippy {
408
- pub compiler : Compiler ,
409
- pub target : Interned < String > ,
410
- }
406
+ macro_rules! tool_extended {
407
+ ( ( $sel: ident, $builder: ident) ,
408
+ $( $name: ident,
409
+ $toolstate: ident,
410
+ $path: expr,
411
+ $tool_name: expr,
412
+ $extra_deps: block; ) +) => {
413
+ $(
414
+ #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
415
+ pub struct $name {
416
+ pub compiler: Compiler ,
417
+ pub target: Interned <String >,
418
+ }
411
419
412
- impl Step for Clippy {
413
- type Output = Option < PathBuf > ;
414
- const DEFAULT : bool = true ;
415
- const ONLY_HOSTS : bool = true ;
420
+ impl Step for $name {
421
+ type Output = Option <PathBuf >;
422
+ const DEFAULT : bool = true ;
423
+ const ONLY_HOSTS : bool = true ;
416
424
417
- fn should_run ( run : ShouldRun ) -> ShouldRun {
418
- let builder = run. builder ;
419
- run. path ( "src/tools/clippy" ) . default_condition ( builder. build . config . extended )
420
- }
425
+ fn should_run( run: ShouldRun ) -> ShouldRun {
426
+ let builder = run. builder;
427
+ run. path( $path ) . default_condition( builder. build. config. extended)
428
+ }
421
429
422
- fn make_run ( run : RunConfig ) {
423
- run. builder . ensure ( Clippy {
424
- compiler : run. builder . compiler ( run. builder . top_stage , run. builder . build . build ) ,
425
- target : run. target ,
426
- } ) ;
430
+ fn make_run( run: RunConfig ) {
431
+ run. builder. ensure( $name {
432
+ compiler: run. builder. compiler( run. builder. top_stage, run. builder. build. build) ,
433
+ target: run. target,
434
+ } ) ;
435
+ }
436
+
437
+ fn run( $sel, $builder: & Builder ) -> Option <PathBuf > {
438
+ $extra_deps
439
+ let toolstate = $builder. build. config. toolstate. $toolstate;
440
+ $builder. ensure( ToolBuild {
441
+ compiler: $sel. compiler,
442
+ target: $sel. target,
443
+ tool: $tool_name,
444
+ mode: Mode :: Librustc ,
445
+ path: $path,
446
+ expectation: toolstate. passes( ToolState :: Compiling ) ,
447
+ } )
448
+ }
449
+ }
450
+ ) +
427
451
}
452
+ }
428
453
429
- fn run ( self , builder : & Builder ) -> Option < PathBuf > {
454
+ tool_extended ! ( ( self , builder) ,
455
+ Cargofmt , rustfmt, "src/tools/rustfmt" , "cargo-fmt" , { } ;
456
+ Clippy , clippy, "src/tools/clippy" , "clippy-driver" , {
430
457
// Clippy depends on procedural macros (serde), which requires a full host
431
458
// compiler to be available, so we need to depend on that.
432
459
builder. ensure( compile:: Rustc {
433
460
compiler: self . compiler,
434
461
target: builder. build. build,
435
462
} ) ;
436
- builder. ensure ( ToolBuild {
437
- compiler : self . compiler ,
438
- target : self . target ,
439
- tool : "clippy-driver" ,
440
- mode : Mode :: Librustc ,
441
- path : "src/tools/clippy" ,
442
- expectation : builder. build . config . toolstate . clippy . passes ( ToolState :: Compiling ) ,
443
- } )
444
- }
445
- }
446
-
447
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
448
- pub struct Rls {
449
- pub compiler : Compiler ,
450
- pub target : Interned < String > ,
451
- }
452
-
453
- impl Step for Rls {
454
- type Output = Option < PathBuf > ;
455
- const DEFAULT : bool = true ;
456
- const ONLY_HOSTS : bool = true ;
457
-
458
- fn should_run ( run : ShouldRun ) -> ShouldRun {
459
- let builder = run. builder ;
460
- run. path ( "src/tools/rls" ) . default_condition ( builder. build . config . extended )
461
- }
462
-
463
- fn make_run ( run : RunConfig ) {
464
- run. builder . ensure ( Rls {
465
- compiler : run. builder . compiler ( run. builder . top_stage , run. builder . build . build ) ,
466
- target : run. target ,
467
- } ) ;
468
- }
469
-
470
- fn run ( self , builder : & Builder ) -> Option < PathBuf > {
463
+ } ;
464
+ Miri , miri, "src/tools/miri" , "miri" , { } ;
465
+ Rls , rls, "src/tools/rls" , "rls" , {
471
466
builder. ensure( native:: Openssl {
472
467
target: self . target,
473
468
} ) ;
@@ -477,87 +472,9 @@ impl Step for Rls {
477
472
compiler: self . compiler,
478
473
target: builder. build. build,
479
474
} ) ;
480
- builder. ensure ( ToolBuild {
481
- compiler : self . compiler ,
482
- target : self . target ,
483
- tool : "rls" ,
484
- mode : Mode :: Librustc ,
485
- path : "src/tools/rls" ,
486
- expectation : builder. build . config . toolstate . rls . passes ( ToolState :: Compiling ) ,
487
- } )
488
- }
489
- }
490
-
491
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
492
- pub struct Rustfmt {
493
- pub compiler : Compiler ,
494
- pub target : Interned < String > ,
495
- }
496
-
497
- impl Step for Rustfmt {
498
- type Output = Option < PathBuf > ;
499
- const DEFAULT : bool = true ;
500
- const ONLY_HOSTS : bool = true ;
501
-
502
- fn should_run ( run : ShouldRun ) -> ShouldRun {
503
- let builder = run. builder ;
504
- run. path ( "src/tools/rustfmt" ) . default_condition ( builder. build . config . extended )
505
- }
506
-
507
- fn make_run ( run : RunConfig ) {
508
- run. builder . ensure ( Rustfmt {
509
- compiler : run. builder . compiler ( run. builder . top_stage , run. builder . build . build ) ,
510
- target : run. target ,
511
- } ) ;
512
- }
513
-
514
- fn run ( self , builder : & Builder ) -> Option < PathBuf > {
515
- builder. ensure ( ToolBuild {
516
- compiler : self . compiler ,
517
- target : self . target ,
518
- tool : "rustfmt" ,
519
- mode : Mode :: Librustc ,
520
- path : "src/tools/rustfmt" ,
521
- expectation : builder. build . config . toolstate . rustfmt . passes ( ToolState :: Compiling ) ,
522
- } )
523
- }
524
- }
525
-
526
-
527
- #[ derive( Debug , Copy , Clone , Hash , PartialEq , Eq ) ]
528
- pub struct Miri {
529
- pub compiler : Compiler ,
530
- pub target : Interned < String > ,
531
- }
532
-
533
- impl Step for Miri {
534
- type Output = Option < PathBuf > ;
535
- const DEFAULT : bool = true ;
536
- const ONLY_HOSTS : bool = true ;
537
-
538
- fn should_run ( run : ShouldRun ) -> ShouldRun {
539
- let build_miri = run. builder . build . config . test_miri ;
540
- run. path ( "src/tools/miri" ) . default_condition ( build_miri)
541
- }
542
-
543
- fn make_run ( run : RunConfig ) {
544
- run. builder . ensure ( Miri {
545
- compiler : run. builder . compiler ( run. builder . top_stage , run. builder . build . build ) ,
546
- target : run. target ,
547
- } ) ;
548
- }
549
-
550
- fn run ( self , builder : & Builder ) -> Option < PathBuf > {
551
- builder. ensure ( ToolBuild {
552
- compiler : self . compiler ,
553
- target : self . target ,
554
- tool : "miri" ,
555
- mode : Mode :: Librustc ,
556
- path : "src/tools/miri" ,
557
- expectation : builder. build . config . toolstate . miri . passes ( ToolState :: Compiling ) ,
558
- } )
559
- }
560
- }
475
+ } ;
476
+ Rustfmt , rustfmt, "src/tools/rustfmt" , "rustfmt" , { } ;
477
+ ) ;
561
478
562
479
impl < ' a > Builder < ' a > {
563
480
/// Get a `Command` which is ready to run `tool` in `stage` built for
0 commit comments