1
- pub mod io ;
1
+ use sysinfo :: { DiskExt , RefreshKind , System , SystemExt } ;
2
2
3
3
use crate :: environment:: Environment ;
4
- use crate :: utils:: io:: { delete_directory, get_files_from_dir} ;
5
- use humansize:: { format_size, BINARY } ;
4
+ use crate :: timer:: Timer ;
5
+ use crate :: utils:: io:: delete_directory;
6
+ use humansize:: BINARY ;
6
7
use std:: time:: Duration ;
7
- use sysinfo:: { DiskExt , RefreshKind , System , SystemExt } ;
8
+
9
+ pub mod artifact_size;
10
+ pub mod io;
8
11
9
12
pub fn format_env_variables ( ) -> String {
10
13
let vars = std:: env:: vars ( ) . map ( |( key, value) | format ! ( "{key}={value}" ) ) . collect :: < Vec < _ > > ( ) ;
@@ -26,28 +29,6 @@ pub fn print_free_disk_space() -> anyhow::Result<()> {
26
29
Ok ( ( ) )
27
30
}
28
31
29
- pub fn print_binary_sizes ( env : & Environment ) -> anyhow:: Result < ( ) > {
30
- use std:: fmt:: Write ;
31
-
32
- let root = env. build_artifacts ( ) . join ( "stage2" ) ;
33
-
34
- let mut files = get_files_from_dir ( & root. join ( "bin" ) , None ) ?;
35
- files. extend ( get_files_from_dir ( & root. join ( "lib" ) , Some ( ".so" ) ) ?) ;
36
- files. sort_unstable ( ) ;
37
-
38
- let mut output = String :: new ( ) ;
39
- for file in files {
40
- let size = std:: fs:: metadata ( file. as_std_path ( ) ) ?. len ( ) ;
41
- let size_formatted = format_size ( size, BINARY ) ;
42
- let name = format ! ( "{}:" , file. file_name( ) . unwrap( ) ) ;
43
- writeln ! ( output, "{name:<50}{size_formatted:>10}" ) ?;
44
- }
45
-
46
- log:: info!( "Rustc artifact size\n {output}" ) ;
47
-
48
- Ok ( ( ) )
49
- }
50
-
51
32
pub fn clear_llvm_files ( env : & Environment ) -> anyhow:: Result < ( ) > {
52
33
// Bootstrap currently doesn't support rebuilding LLVM when PGO options
53
34
// change (or any other llvm-related options); so just clear out the relevant
@@ -58,6 +39,24 @@ pub fn clear_llvm_files(env: &Environment) -> anyhow::Result<()> {
58
39
Ok ( ( ) )
59
40
}
60
41
42
+ /// Write the formatted statistics of the timer to a Github Actions summary.
43
+ pub fn write_timer_to_summary ( path : & str , timer : & Timer ) -> anyhow:: Result < ( ) > {
44
+ use std:: io:: Write ;
45
+
46
+ let mut file = std:: fs:: File :: options ( ) . append ( true ) . create ( true ) . open ( path) ?;
47
+ writeln ! (
48
+ file,
49
+ r#"# Step durations
50
+
51
+ ```
52
+ {}
53
+ ```
54
+ "# ,
55
+ timer. format_stats( )
56
+ ) ?;
57
+ Ok ( ( ) )
58
+ }
59
+
61
60
/// Wraps all output produced within the `func` closure in a CI output group, if we're running in
62
61
/// CI.
63
62
pub fn with_log_group < F : FnOnce ( ) -> R , R > ( group : & str , func : F ) -> R {
0 commit comments