blob: 916129fba5fd3406fa8c67d13b97315addaafede [file] [log] [blame]
Jingwen Chen164e0862021-02-19 00:48:40 -05001package bp2build
2
3import (
4 "android/soong/android"
5 "fmt"
6)
7
8// Simple metrics struct to collect information about a Blueprint to BUILD
9// conversion process.
10type CodegenMetrics struct {
11 // Total number of Soong/Blueprint modules
12 TotalModuleCount int
13
14 // Counts of generated Bazel targets per Bazel rule class
15 RuleClassCount map[string]int
16}
17
18// Print the codegen metrics to stdout.
19func (metrics CodegenMetrics) Print() {
20 generatedTargetCount := 0
21 for _, ruleClass := range android.SortedStringKeys(metrics.RuleClassCount) {
22 count := metrics.RuleClassCount[ruleClass]
23 fmt.Printf("[bp2build] %s: %d targets\n", ruleClass, count)
24 generatedTargetCount += count
25 }
26 fmt.Printf(
27 "[bp2build] Generated %d total BUILD targets from %d Android.bp modules.\n",
28 generatedTargetCount,
29 metrics.TotalModuleCount)
30}