Jingwen Chen | 164e086 | 2021-02-19 00:48:40 -0500 | [diff] [blame] | 1 | package bp2build |
| 2 | |
| 3 | import ( |
| 4 | "android/soong/android" |
| 5 | "fmt" |
| 6 | ) |
| 7 | |
| 8 | // Simple metrics struct to collect information about a Blueprint to BUILD |
| 9 | // conversion process. |
| 10 | type 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. |
| 19 | func (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 | } |