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

Commit 60f562ac authored by Kevin Dagostino's avatar Kevin Dagostino
Browse files

adding /out/soong_injection/metrics/converted_modules_path_map.json

This file can be used by atest/scripts/tools to determine which modules
have been converted and what their bazel build path is.

Test: b build //packages/modules/adb/...
will generate the file at /out/soong_injection/metrics/converted_modules_path_map.json
Also added a unit test to check that the file is created.

{
  "adbd": "//packages/modules/adb",
  "adbd_test": "//packages/modules/adb",
  "add_ext4_encrypt": "//external/e2fsprogs/contrib",
  ....
}

Change-Id: Ibd424c487840d84c8a4fb635828a73541220b36b
parent c518b336
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -242,6 +242,7 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers
	// Simple metrics tracking for bp2build
	metrics := CodegenMetrics{
		ruleClassCount:           make(map[string]uint64),
		convertedModulePathMap:   make(map[string]string),
		convertedModuleTypeCount: make(map[string]uint64),
		totalModuleTypeCount:     make(map[string]uint64),
	}
@@ -272,12 +273,12 @@ func GenerateBazelTargets(ctx *CodegenContext, generateFilegroups bool) (convers
				// target in a BUILD file, we don't autoconvert them.

				// Log the module.
				metrics.AddConvertedModule(m, moduleType, Handcrafted)
				metrics.AddConvertedModule(m, moduleType, dir, Handcrafted)
			} else if aModule, ok := m.(android.Module); ok && aModule.IsConvertedByBp2build() {
				// Handle modules converted to generated targets.

				// Log the module.
				metrics.AddConvertedModule(aModule, moduleType, Generated)
				metrics.AddConvertedModule(aModule, moduleType, dir, Generated)

				// Handle modules with unconverted deps. By default, emit a warning.
				if unconvertedDeps := aModule.GetUnconvertedBp2buildDeps(); len(unconvertedDeps) > 0 {
+6 −0
Original line number Diff line number Diff line
@@ -34,6 +34,12 @@ func CreateSoongInjectionFiles(cfg android.Config, metrics CodegenMetrics) []Baz

	files = append(files, newFile("metrics", "converted_modules.txt", strings.Join(metrics.convertedModules, "\n")))

	convertedModulePathMap, err := json.MarshalIndent(metrics.convertedModulePathMap, "", "\t")
	if err != nil {
		panic(err)
	}
	files = append(files, newFile("metrics", "converted_modules_path_map.json", string(convertedModulePathMap)))

	files = append(files, newFile("product_config", "soong_config_variables.bzl", cfg.Bp2buildSoongConfigDefinitions.String()))

	files = append(files, newFile("product_config", "arch_configuration.bzl", android.StarlarkArchConfigurations()))
+4 −0
Original line number Diff line number Diff line
@@ -115,6 +115,10 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) {
			dir:      "metrics",
			basename: "converted_modules.txt",
		},
		{
			dir:      "metrics",
			basename: "converted_modules_path_map.json",
		},
		{
			dir:      "product_config",
			basename: "soong_config_variables.bzl",
+6 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ import (
	"android/soong/android"
	"android/soong/shared"
	"android/soong/ui/metrics/bp2build_metrics_proto"

	"github.com/google/blueprint"
)

@@ -38,6 +39,9 @@ type CodegenMetrics struct {
	// List of converted modules
	convertedModules []string

	// Map of converted modules and paths to call
	convertedModulePathMap map[string]string

	// Counts of converted modules by module type.
	convertedModuleTypeCount map[string]uint64

@@ -147,10 +151,11 @@ const (
	Handcrafted
)

func (metrics *CodegenMetrics) AddConvertedModule(m blueprint.Module, moduleType string, conversionType ConversionType) {
func (metrics *CodegenMetrics) AddConvertedModule(m blueprint.Module, moduleType string, dir string, conversionType ConversionType) {
	// Undo prebuilt_ module name prefix modifications
	moduleName := android.RemoveOptionalPrebuiltPrefix(m.Name())
	metrics.convertedModules = append(metrics.convertedModules, moduleName)
	metrics.convertedModulePathMap[moduleName] = "//" + dir
	metrics.convertedModuleTypeCount[moduleType] += 1
	metrics.totalModuleTypeCount[moduleType] += 1