Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d7f2e41 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix false pos in bp2build-prog due to prebulits" into main

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