Fix bp2build-progress generating an empty converted_modules list, and

duplicate module names.

We were using the value receiver on AddConvertedModule before, which
didn't actually mutate the internal slice state.

Test: Run bp2build-progress.py
Change-Id: Ic60f8f6214a91dc129abf62c57dd0b85efffb283
This commit is contained in:
Jingwen Chen 2021-09-20 10:31:46 +00:00
parent 0c7ca97876
commit afb84bd78f
2 changed files with 3 additions and 4 deletions

View file

@ -308,9 +308,8 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers
}
}
targets = generateBazelTargets(bpCtx, aModule)
metrics.AddConvertedModule(m.Name())
for _, t := range targets {
// only add targets that exist in Soong to compatibility layer
metrics.AddConvertedModule(m.Name())
metrics.RuleClassCount[t.ruleClass] += 1
}
} else {

View file

@ -24,7 +24,7 @@ type CodegenMetrics struct {
}
// Print the codegen metrics to stdout.
func (metrics CodegenMetrics) Print() {
func (metrics *CodegenMetrics) Print() {
generatedTargetCount := 0
for _, ruleClass := range android.SortedStringKeys(metrics.RuleClassCount) {
count := metrics.RuleClassCount[ruleClass]
@ -40,7 +40,7 @@ func (metrics CodegenMetrics) Print() {
strings.Join(metrics.moduleWithUnconvertedDepsMsgs, "\n\t"))
}
func (metrics CodegenMetrics) AddConvertedModule(moduleName string) {
func (metrics *CodegenMetrics) AddConvertedModule(moduleName string) {
// Undo prebuilt_ module name prefix modifications
moduleName = android.RemoveOptionalPrebuiltPrefix(moduleName)
metrics.convertedModules = append(metrics.convertedModules, moduleName)