Log bp2build_metrics .pb

Also share `Save(pb proto.Message, filepath string)`

Bug: 201539536
Test: bp2build_metrics.pb has expected content & path
Test: m nothing
Test: {bp2build,mixed_{libc,droid}}.sh
Test: CI
Change-Id: I7d8ad87fca6a4b0355010090a527f5ae67b27c88
This commit is contained in:
Alex Márquez Pérez Muñíz Díaz Púras Thaureaux
2021-11-10 09:55:20 -05:00
parent 484aa25875
commit 947fdbfdee
10 changed files with 136 additions and 34 deletions

View File

@@ -537,6 +537,7 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
// for queryview, since that's a total repo-wide conversion and there's a
// 1:1 mapping for each module.
metrics.Print()
writeBp2BuildMetrics(&metrics, configuration)
ninjaDeps = append(ninjaDeps, codegenContext.AdditionalNinjaDeps()...)
ninjaDeps = append(ninjaDeps, symlinkForestDeps...)
@@ -546,3 +547,13 @@ func runBp2Build(configuration android.Config, extraNinjaDeps []string) {
// Create an empty bp2build marker file.
touch(shared.JoinPath(topDir, bp2buildMarker))
}
// Write Bp2Build metrics into $LOG_DIR
func writeBp2BuildMetrics(metrics *bp2build.CodegenMetrics, configuration android.Config) {
metricsDir := configuration.Getenv("LOG_DIR")
if len(metricsDir) < 1 {
fmt.Fprintf(os.Stderr, "\nMissing required env var for generating bp2build metrics: LOG_DIR\n")
os.Exit(1)
}
metrics.Write(metricsDir)
}