@@ -862,6 +862,18 @@ impl RustwideBuilder {
862
862
} )
863
863
} ;
864
864
865
+ if let Some ( compiler_metric_target_dir) = & self . config . compiler_metrics_collection_path {
866
+ let metric_output = build. host_target_dir ( ) . join ( "metrics/" ) ;
867
+ info ! (
868
+ "found {} files in metric dir, copy over to {} (exists: {})" ,
869
+ fs:: read_dir( & metric_output) ?. count( ) ,
870
+ & compiler_metric_target_dir. to_string_lossy( ) ,
871
+ & compiler_metric_target_dir. exists( ) ,
872
+ ) ;
873
+ copy_dir_all ( & metric_output, compiler_metric_target_dir) ?;
874
+ fs:: remove_dir_all ( & metric_output) ?;
875
+ }
876
+
865
877
// For proc-macros, cargo will put the output in `target/doc`.
866
878
// Move it to the target-specific directory for consistency with other builds.
867
879
// NOTE: don't rename this if the build failed, because `target/doc` won't exist.
@@ -945,7 +957,7 @@ impl RustwideBuilder {
945
957
] ;
946
958
947
959
rustdoc_flags_extras. extend ( UNCONDITIONAL_ARGS . iter ( ) . map ( |& s| s. to_owned ( ) ) ) ;
948
- let cargo_args = metadata. cargo_args ( & cargo_args, & rustdoc_flags_extras) ;
960
+ let mut cargo_args = metadata. cargo_args ( & cargo_args, & rustdoc_flags_extras) ;
949
961
950
962
// If the explicit target is not a tier one target, we need to install it.
951
963
let has_build_std = cargo_args. windows ( 2 ) . any ( |args| {
@@ -966,6 +978,21 @@ impl RustwideBuilder {
966
978
command = command. env ( key, val) ;
967
979
}
968
980
981
+ if self . config . compiler_metrics_collection_path . is_some ( ) {
982
+ // set the `./target/metrics/` directory inside the build container
983
+ // as a target directory for the metric files.
984
+ let flag = "-Zmetrics-dir=/opt/rustwide/target/metrics" ;
985
+
986
+ // this is how we can reach it from outside the container.
987
+ fs:: create_dir_all ( build. host_target_dir ( ) . join ( "metrics/" ) ) ?;
988
+
989
+ let rustflags = toml:: Value :: try_from ( vec ! [ flag] )
990
+ . expect ( "serializing a string should never fail" )
991
+ . to_string ( ) ;
992
+ cargo_args. push ( "--config" . into ( ) ) ;
993
+ cargo_args. push ( format ! ( "build.rustflags={rustflags}" ) ) ;
994
+ }
995
+
969
996
Ok ( command. args ( & cargo_args) )
970
997
}
971
998
0 commit comments