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 |
Liz Kammer | ba3ea16 | 2021-02-17 13:22:03 -0500 | [diff] [blame] | 16 | |
| 17 | // Total number of handcrafted targets |
| 18 | handCraftedTargetCount int |
Jingwen Chen | 164e086 | 2021-02-19 00:48:40 -0500 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | // Print the codegen metrics to stdout. |
| 22 | func (metrics CodegenMetrics) Print() { |
| 23 | generatedTargetCount := 0 |
| 24 | for _, ruleClass := range android.SortedStringKeys(metrics.RuleClassCount) { |
| 25 | count := metrics.RuleClassCount[ruleClass] |
| 26 | fmt.Printf("[bp2build] %s: %d targets\n", ruleClass, count) |
| 27 | generatedTargetCount += count |
| 28 | } |
| 29 | fmt.Printf( |
Liz Kammer | ba3ea16 | 2021-02-17 13:22:03 -0500 | [diff] [blame] | 30 | "[bp2build] Generated %d total BUILD targets and included %d handcrafted BUILD targets from %d Android.bp modules.\n", |
Jingwen Chen | 164e086 | 2021-02-19 00:48:40 -0500 | [diff] [blame] | 31 | generatedTargetCount, |
Liz Kammer | ba3ea16 | 2021-02-17 13:22:03 -0500 | [diff] [blame] | 32 | metrics.handCraftedTargetCount, |
Jingwen Chen | 164e086 | 2021-02-19 00:48:40 -0500 | [diff] [blame] | 33 | metrics.TotalModuleCount) |
| 34 | } |