Merge "Fix bp2build-progress generating an empty converted_modules list, and duplicate module names." am: b3c3d9a2d5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1831633

Change-Id: Ib004dcae1f80d6aa98f53c5be24d5c8790bc7b4f
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index f7b392b..07f492e 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -308,9 +308,8 @@
 					}
 				}
 				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 {
diff --git a/bp2build/metrics.go b/bp2build/metrics.go
index 55b928b..9e7b3b6 100644
--- a/bp2build/metrics.go
+++ b/bp2build/metrics.go
@@ -24,7 +24,7 @@
 }
 
 // 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 @@
 		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)