Report mkfile metrics with --mk-metrics
Combined with roboleaf CI changes to pass this flag and subsequent
pipeline changes, this will allow basic mkfile metrics to be
dashboarded, which will help track mk2bp progress.
Bug: 217764943
Test: manual; verified mk_metrics.pb is generated iff --mk-metrics is
specified, used printproto on result
Change-Id: I348994b4d7e3479d0dc04de0276b94a702aac95b
diff --git a/ui/build/finder.go b/ui/build/finder.go
index 68efe21..262de3d 100644
--- a/ui/build/finder.go
+++ b/ui/build/finder.go
@@ -138,6 +138,17 @@
ctx.Fatalf("Could not export module list: %v", err)
}
+ // Gate collecting/reporting mk metrics on builds that specifically request
+ // it, as identifying the total number of mk files adds 4-5ms onto null
+ // builds.
+ if config.reportMkMetrics {
+ androidMksTotal := f.FindNamedAt(".", "Android.mk")
+
+ ctx.Metrics.SetToplevelMakefiles(len(androidMks))
+ ctx.Metrics.SetTotalMakefiles(len(androidMksTotal))
+ ctx.Metrics.DumpMkMetrics(config.MkMetrics())
+ }
+
// Stop searching a subdirectory recursively after finding a CleanSpec.mk.
cleanSpecs := f.FindFirstNamedAt(".", "CleanSpec.mk")
err = dumpListToFile(ctx, config, cleanSpecs, filepath.Join(dumpDir, "CleanSpec.mk.list"))