164e0867fc
Sample output: [bp2build] cc_library_headers: 5 targets [bp2build] cc_object: 5 targets [bp2build] filegroup: 4 targets [bp2build] genrule: 4 targets [bp2build] sh_binary: 1 targets [bp2build] Generated 19 total BUILD targets from 39270 Android.bp modules. This CL adds an additional CodegenMetrics return value to GenerateBazelTargets calls, which are called from bp2build, queryview, and their tests. For this UI, we only want to use it for bp2build, and not queryview or tests, since it's not useful for the former, and can pollute the CLI for the latter. Test: build/bazel/scripts/milestone-2/demo.sh Change-Id: Ic84307a1ed1a25e360c9b23459e5449d932bc2e7
30 lines
822 B
Go
30 lines
822 B
Go
package bp2build
|
|
|
|
import (
|
|
"android/soong/android"
|
|
"fmt"
|
|
)
|
|
|
|
// Simple metrics struct to collect information about a Blueprint to BUILD
|
|
// conversion process.
|
|
type CodegenMetrics struct {
|
|
// Total number of Soong/Blueprint modules
|
|
TotalModuleCount int
|
|
|
|
// Counts of generated Bazel targets per Bazel rule class
|
|
RuleClassCount map[string]int
|
|
}
|
|
|
|
// Print the codegen metrics to stdout.
|
|
func (metrics CodegenMetrics) Print() {
|
|
generatedTargetCount := 0
|
|
for _, ruleClass := range android.SortedStringKeys(metrics.RuleClassCount) {
|
|
count := metrics.RuleClassCount[ruleClass]
|
|
fmt.Printf("[bp2build] %s: %d targets\n", ruleClass, count)
|
|
generatedTargetCount += count
|
|
}
|
|
fmt.Printf(
|
|
"[bp2build] Generated %d total BUILD targets from %d Android.bp modules.\n",
|
|
generatedTargetCount,
|
|
metrics.TotalModuleCount)
|
|
}
|