@@ -9,8 +9,8 @@ pub fn out_dir() -> PathBuf {
9
9
env:: var_os ( "TMPDIR" ) . unwrap ( ) . into ( )
10
10
}
11
11
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 ( ) ;
14
14
let mut cmd = Command :: new ( rustc) ;
15
15
cmd. arg ( "--out-dir" ) . arg ( out_dir ( ) ) . arg ( "-L" ) . arg ( out_dir ( ) ) ;
16
16
cmd
@@ -33,14 +33,18 @@ pub fn aux_build() -> AuxBuildInvocationBuilder {
33
33
AuxBuildInvocationBuilder :: new ( )
34
34
}
35
35
36
+ pub fn rustdoc ( ) -> RustdocInvocationBuilder {
37
+ RustdocInvocationBuilder :: new ( )
38
+ }
39
+
36
40
#[ derive( Debug ) ]
37
41
pub struct RustcInvocationBuilder {
38
42
cmd : Command ,
39
43
}
40
44
41
45
impl RustcInvocationBuilder {
42
46
fn new ( ) -> Self {
43
- let cmd = setup_common_build_cmd ( ) ;
47
+ let cmd = setup_common_build_cmd ( "RUSTC" ) ;
44
48
Self { cmd }
45
49
}
46
50
@@ -74,7 +78,7 @@ pub struct AuxBuildInvocationBuilder {
74
78
75
79
impl AuxBuildInvocationBuilder {
76
80
fn new ( ) -> Self {
77
- let mut cmd = setup_common_build_cmd ( ) ;
81
+ let mut cmd = setup_common_build_cmd ( "RUSTC" ) ;
78
82
cmd. arg ( "--crate-type=lib" ) ;
79
83
Self { cmd }
80
84
}
@@ -97,6 +101,35 @@ impl AuxBuildInvocationBuilder {
97
101
}
98
102
}
99
103
104
+ #[ derive( Debug ) ]
105
+ pub struct RustdocInvocationBuilder {
106
+ cmd : Command ,
107
+ }
108
+
109
+ impl RustdocInvocationBuilder {
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
+
100
133
fn run_common ( bin_name : & str ) -> ( Command , Output ) {
101
134
let target = env:: var ( "TARGET" ) . unwrap ( ) ;
102
135
0 commit comments