@@ -27,6 +27,8 @@ pub struct BuildConfig {
2727 /// An optional wrapper, if any, used to wrap rustc invocations
2828 pub rustc_wrapper : Option < ProcessBuilder > ,
2929 pub rustfix_diagnostic_server : RefCell < Option < RustfixDiagnosticServer > > ,
30+ /// Whether or not Cargo should cache compiler output on disk.
31+ cache_messages : bool ,
3032}
3133
3234impl BuildConfig {
@@ -87,6 +89,7 @@ impl BuildConfig {
8789 }
8890 let cfg_jobs: Option < u32 > = config. get ( "build.jobs" ) ?;
8991 let jobs = jobs. or ( cfg_jobs) . unwrap_or ( :: num_cpus:: get ( ) as u32 ) ;
92+
9093 Ok ( BuildConfig {
9194 requested_target : target,
9295 jobs,
@@ -97,10 +100,23 @@ impl BuildConfig {
97100 build_plan : false ,
98101 rustc_wrapper : None ,
99102 rustfix_diagnostic_server : RefCell :: new ( None ) ,
103+ cache_messages : config. cli_unstable ( ) . cache_messages ,
100104 } )
101105 }
102106
103- pub fn json_messages ( & self ) -> bool {
107+ /// Whether or not Cargo should cache compiler messages on disk.
108+ pub fn cache_messages ( & self ) -> bool {
109+ self . cache_messages
110+ && match self . message_format {
111+ MessageFormat :: Human | MessageFormat :: Json => true ,
112+ // short is currently not supported
113+ MessageFormat :: Short => false ,
114+ }
115+ }
116+
117+ /// Whether or not the *user* wants JSON output. Whether or not rustc
118+ /// actually uses JSON is decided in `add_error_format`.
119+ pub fn emit_json ( & self ) -> bool {
104120 self . message_format == MessageFormat :: Json
105121 }
106122
0 commit comments