@@ -9,8 +9,8 @@ pub fn out_dir() -> PathBuf {
99 env:: var_os ( "TMPDIR" ) . unwrap ( ) . into ( )
1010}
1111
12- fn setup_common_build_cmd ( ) -> Command {
13- let rustc = env:: var ( "RUSTC" ) . unwrap ( ) ;
12+ fn setup_common_build_cmd ( command : & str ) -> Command {
13+ let rustc = env:: var ( command ) . unwrap ( ) ;
1414 let mut cmd = Command :: new ( rustc) ;
1515 cmd. arg ( "--out-dir" ) . arg ( out_dir ( ) ) . arg ( "-L" ) . arg ( out_dir ( ) ) ;
1616 cmd
@@ -33,14 +33,18 @@ pub fn aux_build() -> AuxBuildInvocationBuilder {
3333 AuxBuildInvocationBuilder :: new ( )
3434}
3535
36+ pub fn rustdoc ( ) -> Rustdoc {
37+ Rustdoc :: new ( )
38+ }
39+
3640#[ derive( Debug ) ]
3741pub struct RustcInvocationBuilder {
3842 cmd : Command ,
3943}
4044
4145impl RustcInvocationBuilder {
4246 fn new ( ) -> Self {
43- let cmd = setup_common_build_cmd ( ) ;
47+ let cmd = setup_common_build_cmd ( "RUSTC" ) ;
4448 Self { cmd }
4549 }
4650
@@ -74,7 +78,7 @@ pub struct AuxBuildInvocationBuilder {
7478
7579impl AuxBuildInvocationBuilder {
7680 fn new ( ) -> Self {
77- let mut cmd = setup_common_build_cmd ( ) ;
81+ let mut cmd = setup_common_build_cmd ( "RUSTC" ) ;
7882 cmd. arg ( "--crate-type=lib" ) ;
7983 Self { cmd }
8084 }
@@ -97,6 +101,35 @@ impl AuxBuildInvocationBuilder {
97101 }
98102}
99103
104+ #[ derive( Debug ) ]
105+ pub struct Rustdoc {
106+ cmd : Command ,
107+ }
108+
109+ impl Rustdoc {
110+ fn new ( ) -> Self {
111+ let cmd = setup_common_build_cmd ( "RUSTDOC" ) ;
112+ Self { cmd }
113+ }
114+
115+ pub fn arg ( & mut self , arg : & str ) -> & mut Self {
116+ self . cmd . arg ( arg) ;
117+ self
118+ }
119+
120+ #[ track_caller]
121+ pub fn run ( & mut self ) -> Output {
122+ let caller_location = std:: panic:: Location :: caller ( ) ;
123+ let caller_line_number = caller_location. line ( ) ;
124+
125+ let output = self . cmd . output ( ) . unwrap ( ) ;
126+ if !output. status . success ( ) {
127+ handle_failed_output ( & format ! ( "{:#?}" , self . cmd) , output, caller_line_number) ;
128+ }
129+ output
130+ }
131+ }
132+
100133fn run_common ( bin_name : & str ) -> ( Command , Output ) {
101134 let target = env:: var ( "TARGET" ) . unwrap ( ) ;
102135
0 commit comments