1package 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 // Total number of handcrafted targets 18 handCraftedTargetCount int 19} 20 21// Print the codegen metrics to stdout. 22func (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( 30 "[bp2build] Generated %d total BUILD targets and included %d handcrafted BUILD targets from %d Android.bp modules.\n", 31 generatedTargetCount, 32 metrics.handCraftedTargetCount, 33 metrics.TotalModuleCount) 34} 35