Loading bp2build/conversion.go +5 −1 Original line number Diff line number Diff line Loading @@ -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 { Loading bp2build/conversion_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -134,7 +134,7 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) { }, { dir: "metrics", basename: "converted_modules.txt", basename: "converted_modules.json", }, { dir: "metrics", Loading bp2build/metrics.go +13 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 { Loading Loading @@ -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 Loading Loading
bp2build/conversion.go +5 −1 Original line number Diff line number Diff line Loading @@ -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 { Loading
bp2build/conversion_test.go +1 −1 Original line number Diff line number Diff line Loading @@ -134,7 +134,7 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) { }, { dir: "metrics", basename: "converted_modules.txt", basename: "converted_modules.json", }, { dir: "metrics", Loading
bp2build/metrics.go +13 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 { Loading Loading @@ -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 Loading