File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed
core/compiler/fingerprint Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -397,6 +397,7 @@ use crate::core::compiler::unit_graph::UnitDep;
397397use crate :: util;
398398use crate :: util:: errors:: CargoResult ;
399399use crate :: util:: interning:: InternedString ;
400+ use crate :: util:: log_message:: LogMessage ;
400401use crate :: util:: { StableHasher , internal, path_args} ;
401402use crate :: { CARGO_ENV , GlobalContext } ;
402403
@@ -448,6 +449,18 @@ pub fn prepare_target(
448449 return Ok ( Job :: new_fresh ( ) ) ;
449450 } ;
450451
452+ if let Some ( logger) = bcx. logger {
453+ // Dont log FreshBuild as it is noisy.
454+ if !dirty_reason. is_fresh_build ( ) {
455+ logger. log ( LogMessage :: Rebuild {
456+ package_id : unit. pkg . package_id ( ) . to_spec ( ) ,
457+ target : unit. target . clone ( ) ,
458+ mode : unit. mode ,
459+ cause : dirty_reason. clone ( ) ,
460+ } ) ;
461+ }
462+ }
463+
451464 // We're going to rebuild, so ensure the source of the crate passes all
452465 // verification checks before we build it.
453466 //
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use serde::Serialize;
1010use crate :: core:: Target ;
1111use crate :: core:: compiler:: CompilationSection ;
1212use crate :: core:: compiler:: CompileMode ;
13+ use crate :: core:: compiler:: fingerprint:: DirtyReason ;
1314
1415/// A log message.
1516///
@@ -39,6 +40,13 @@ pub enum LogMessage {
3940 #[ serde( skip_serializing_if = "Vec::is_empty" ) ]
4041 sections : Vec < ( String , CompilationSection ) > ,
4142 } ,
43+ /// Emitted when a unit needs to be rebuilt.
44+ Rebuild {
45+ package_id : PackageIdSpec ,
46+ target : Target ,
47+ mode : CompileMode ,
48+ cause : DirtyReason ,
49+ } ,
4250}
4351
4452impl LogMessage {
Original file line number Diff line number Diff line change @@ -227,6 +227,23 @@ fn log_rebuild_reason_file_changed() {
227227 "...": "{...}",
228228 "reason": "build-started"
229229 },
230+ {
231+ "cause": {
232+ "dirty_reason": "fs-status-outdated",
233+ "fs_status": "stale-item",
234+ "reference": "[ROOT]/foo/target/debug/.fingerprint/foo-[HASH]/dep-lib-foo",
235+ "reference_mtime": "{...}",
236+ "stale": "[ROOT]/foo/src/lib.rs",
237+ "stale_item": "changed-file",
238+ "stale_mtime": "{...}"
239+ },
240+ "mode": "check",
241+ "package_id": "path+[ROOTURL]/foo#0.0.0",
242+ "reason": "rebuild",
243+ "run_id": "[..]T[..]Z-[..]",
244+ "target": "{...}",
245+ "timestamp": "[..]T[..]Z"
246+ },
230247 {
231248 "...": "{...}",
232249 "reason": "timing-info"
You can’t perform that action at this time.
0 commit comments