11use std:: fmt:: { Display , Formatter } ;
22
33use crate :: core:: build_steps:: compile:: { Std , Sysroot } ;
4- use crate :: core:: build_steps:: tool:: RustcPerf ;
4+ use crate :: core:: build_steps:: tool:: { RustcPerf , Rustdoc } ;
55use crate :: core:: builder:: Builder ;
66use crate :: core:: config:: DebuginfoLevel ;
77use crate :: utils:: exec:: { BootstrapCommand , command} ;
@@ -52,6 +52,18 @@ enum PerfCommand {
5252 } ,
5353}
5454
55+ impl PerfCommand {
56+ fn shared_opts ( & self ) -> Option < & SharedOpts > {
57+ match self {
58+ PerfCommand :: Eprintln { opts, .. }
59+ | PerfCommand :: Samply { opts, .. }
60+ | PerfCommand :: Cachegrind { opts, .. }
61+ | PerfCommand :: Benchmark { opts, .. } => Some ( opts) ,
62+ PerfCommand :: Compare { .. } => None ,
63+ }
64+ }
65+ }
66+
5567#[ derive( Debug , Clone , clap:: Parser ) ]
5668struct SharedOpts {
5769 /// Select the benchmarks that you want to run (separated by commas).
@@ -76,7 +88,7 @@ struct SharedOpts {
7688 profiles : Vec < Profile > ,
7789}
7890
79- #[ derive( Clone , Copy , Debug , clap:: ValueEnum ) ]
91+ #[ derive( Clone , Copy , Debug , PartialEq , clap:: ValueEnum ) ]
8092#[ value( rename_all = "PascalCase" ) ]
8193pub enum Profile {
8294 Check ,
@@ -140,6 +152,13 @@ Consider setting `rust.debuginfo-level = 1` in `config.toml`."#);
140152
141153 let compiler = builder. compiler ( builder. top_stage , builder. config . build ) ;
142154 builder. ensure ( Std :: new ( compiler, builder. config . build ) ) ;
155+
156+ if let Some ( opts) = args. cmd . shared_opts ( ) {
157+ if opts. profiles . contains ( & Profile :: Doc ) {
158+ builder. ensure ( Rustdoc { compiler } ) ;
159+ }
160+ }
161+
143162 let sysroot = builder. ensure ( Sysroot :: new ( compiler) ) ;
144163 let rustc = sysroot. join ( "bin/rustc" ) ;
145164
0 commit comments