3
3
//! This module implements some simple tracking information for timing of how
4
4
//! long it takes for different units to compile.
5
5
use super :: { CompileMode , Unit } ;
6
+ use crate :: core:: compiler:: BuildContext ;
6
7
use crate :: core:: PackageId ;
7
8
use crate :: util:: machine_message:: { self , Message } ;
8
9
use crate :: util:: { CargoResult , Config } ;
@@ -24,6 +25,8 @@ pub struct Timings<'a, 'cfg> {
24
25
start : Instant ,
25
26
/// A rendered string of when compilation started.
26
27
start_str : String ,
28
+ /// Some information to display about rustc.
29
+ rustc_info : String ,
27
30
/// A summary of the root units.
28
31
///
29
32
/// Tuples of `(package_description, target_descrptions)`.
@@ -76,11 +79,7 @@ struct Concurrency {
76
79
}
77
80
78
81
impl < ' a , ' cfg > Timings < ' a , ' cfg > {
79
- pub fn new (
80
- config : & ' cfg Config ,
81
- root_units : & [ Unit < ' _ > ] ,
82
- profile : String ,
83
- ) -> Timings < ' a , ' cfg > {
82
+ pub fn new ( bcx : & BuildContext < ' a , ' cfg > , root_units : & [ Unit < ' _ > ] ) -> Timings < ' a , ' cfg > {
84
83
let mut root_map: HashMap < PackageId , Vec < String > > = HashMap :: new ( ) ;
85
84
for unit in root_units {
86
85
let target_desc = unit. target . description_named ( ) ;
@@ -98,20 +97,28 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
98
97
. collect ( ) ;
99
98
let start_str = format ! ( "{}" , humantime:: format_rfc3339_seconds( SystemTime :: now( ) ) ) ;
100
99
let has_report = |what| {
101
- config
100
+ bcx . config
102
101
. cli_unstable ( )
103
102
. timings
104
103
. as_ref ( )
105
104
. map_or ( false , |t| t. iter ( ) . any ( |opt| opt == what) )
106
105
} ;
106
+ let rustc_info = render_rustc_info ( bcx) ;
107
+ let profile = if bcx. build_config . release {
108
+ "release"
109
+ } else {
110
+ "dev"
111
+ }
112
+ . to_string ( ) ;
107
113
108
114
Timings {
109
- config,
115
+ config : bcx . config ,
110
116
report_html : has_report ( "html" ) ,
111
117
report_info : has_report ( "info" ) ,
112
118
report_json : has_report ( "json" ) ,
113
- start : config. creation_time ( ) ,
119
+ start : bcx . config . creation_time ( ) ,
114
120
start_str,
121
+ rustc_info,
115
122
root_targets,
116
123
profile,
117
124
total_fresh : 0 ,
@@ -270,30 +277,27 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
270
277
<tr>
271
278
<td>Profile:</td><td>{}</td>
272
279
</tr>
273
- <tr>
274
- <td>Fresh units:</td>
275
- <td>{}</td>
276
- </tr>
277
- <tr>
278
- <td>Dirty units:</td>
279
- <td>{}</td>
280
- </tr>
281
- <tr>
282
- <td>Total units:</td>
283
- <td>{}</td>
284
- </tr>
285
- <tr>
286
- <td>Max concurrency:</td>
287
- <td>{}</td>
288
- </tr>
289
- <tr>
290
- <td>Build start:</td>
291
- <td>{}</td>
292
- </tr>
293
- <tr>
294
- <td>Total time:</td>
295
- <td>{}</td>
296
- </tr>
280
+ <tr>
281
+ <td>Fresh units:</td><td>{}</td>
282
+ </tr>
283
+ <tr>
284
+ <td>Dirty units:</td><td>{}</td>
285
+ </tr>
286
+ <tr>
287
+ <td>Total units:</td><td>{}</td>
288
+ </tr>
289
+ <tr>
290
+ <td>Max concurrency:</td><td>{}</td>
291
+ </tr>
292
+ <tr>
293
+ <td>Build start:</td><td>{}</td>
294
+ </tr>
295
+ <tr>
296
+ <td>Total time:</td><td>{}</td>
297
+ </tr>
298
+ <tr>
299
+ <td>rustc:</td><td>{}</td>
300
+ </tr>
297
301
298
302
</table>
299
303
"# ,
@@ -305,6 +309,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
305
309
max_concurrency,
306
310
self . start_str,
307
311
total_time,
312
+ self . rustc_info,
308
313
) ?;
309
314
Ok ( ( ) )
310
315
}
@@ -674,6 +679,24 @@ fn draw_graph_axes(f: &mut File, graph_height: u32, duration: u32) -> CargoResul
674
679
Ok ( graph_width)
675
680
}
676
681
682
+ fn render_rustc_info ( bcx : & BuildContext < ' _ , ' _ > ) -> String {
683
+ let version = bcx
684
+ . rustc
685
+ . verbose_version
686
+ . lines ( )
687
+ . next ( )
688
+ . expect ( "rustc version" ) ;
689
+ let requested_target = bcx
690
+ . build_config
691
+ . requested_target
692
+ . as_ref ( )
693
+ . map_or ( "Host" , String :: as_str) ;
694
+ format ! (
695
+ "{}<br>Host: {}<br>Target: {}" ,
696
+ version, bcx. rustc. host, requested_target
697
+ )
698
+ }
699
+
677
700
static HTML_TMPL : & str = r#"
678
701
<html>
679
702
<head>
801
824
}
802
825
803
826
.summary-table td:first-child {
827
+ vertical-align: top;
804
828
text-align: right;
805
829
}
806
830
0 commit comments