compat layer. The list of converted modules is used for tracking bp2build progress. The module_name_to_label aliases weren't really adding much value to mixed builds, so let's drop the feature for now and simplify the code. Test: CI Test: USE_BAZEL_ANALYSIS=1 m droid Change-Id: I3269344cfe6d1c72c108d66c6e820bc0ec19bb34
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package bp2build
|
|
|
|
import (
|
|
"android/soong/android"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// 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
|
|
|
|
// Total number of handcrafted targets
|
|
handCraftedTargetCount int
|
|
|
|
moduleWithUnconvertedDepsMsgs []string
|
|
|
|
convertedModules []string
|
|
}
|
|
|
|
// 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 and included %d handcrafted BUILD targets from %d Android.bp modules.\n With %d modules with unconverted deps \n\t%s",
|
|
generatedTargetCount,
|
|
metrics.handCraftedTargetCount,
|
|
metrics.TotalModuleCount,
|
|
len(metrics.moduleWithUnconvertedDepsMsgs),
|
|
strings.Join(metrics.moduleWithUnconvertedDepsMsgs, "\n\t"))
|
|
}
|
|
|
|
func (metrics CodegenMetrics) AddConvertedModule(moduleName string) {
|
|
// Undo prebuilt_ module name prefix modifications
|
|
moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName)
|
|
metrics.convertedModules = append(metrics.convertedModules, moduleName)
|
|
}
|