diff --git a/bp2build/conversion.go b/bp2build/conversion.go index 77914194f..35a1400a0 100644 --- a/bp2build/conversion.go +++ b/bp2build/conversion.go @@ -48,7 +48,11 @@ func soongInjectionFiles(cfg android.Config, metrics CodegenMetrics) ([]BazelFil } files = append(files, newFile("apex_toolchain", "constants.bzl", apexToolchainVars)) - files = append(files, newFile("metrics", "converted_modules.txt", strings.Join(metrics.Serialize().ConvertedModules, "\n"))) + if buf, err := json.MarshalIndent(metrics.convertedModuleWithType, "", " "); err != nil { + return []BazelFile{}, err + } else { + files = append(files, newFile("metrics", "converted_modules.json", string(buf))) + } convertedModulePathMap, err := json.MarshalIndent(metrics.convertedModulePathMap, "", "\t") if err != nil { diff --git a/bp2build/conversion_test.go b/bp2build/conversion_test.go index cbffaa083..89dd38ef0 100644 --- a/bp2build/conversion_test.go +++ b/bp2build/conversion_test.go @@ -134,7 +134,7 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) { }, { dir: "metrics", - basename: "converted_modules.txt", + basename: "converted_modules.json", }, { dir: "metrics", diff --git a/bp2build/metrics.go b/bp2build/metrics.go index 00f21c8a7..20002c67f 100644 --- a/bp2build/metrics.go +++ b/bp2build/metrics.go @@ -9,11 +9,17 @@ import ( "android/soong/android" "android/soong/shared" "android/soong/ui/metrics/bp2build_metrics_proto" + "google.golang.org/protobuf/proto" "github.com/google/blueprint" ) +type moduleInfo struct { + Name string `json:"name"` + Type string `json:"type"` +} + // CodegenMetrics represents information about the Blueprint-to-BUILD // conversion process. // Use CreateCodegenMetrics() to get a properly initialized instance @@ -30,6 +36,9 @@ type CodegenMetrics struct { // Map of converted modules and paths to call // NOTE: NOT in the .proto convertedModulePathMap map[string]string + + // Name and type of converted modules + convertedModuleWithType []moduleInfo } func CreateCodegenMetrics() CodegenMetrics { @@ -191,6 +200,10 @@ func (metrics *CodegenMetrics) AddConvertedModule(m blueprint.Module, moduleType // Undo prebuilt_ module name prefix modifications moduleName := android.RemoveOptionalPrebuiltPrefix(m.Name()) metrics.serialized.ConvertedModules = append(metrics.serialized.ConvertedModules, moduleName) + metrics.convertedModuleWithType = append(metrics.convertedModuleWithType, moduleInfo{ + moduleName, + moduleType, + }) metrics.convertedModulePathMap[moduleName] = "//" + dir metrics.serialized.ConvertedModuleTypeCount[moduleType] += 1 metrics.serialized.TotalModuleTypeCount[moduleType] += 1