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
diff --git a/bp2build/build_conversion.go b/bp2build/build_conversion.go
index ee162b2..6598b6f 100644
--- a/bp2build/build_conversion.go
+++ b/bp2build/build_conversion.go
@@ -242,6 +242,7 @@
// 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 @@
// 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 {
diff --git a/bp2build/conversion.go b/bp2build/conversion.go
index b6190c6..522c10e 100644
--- a/bp2build/conversion.go
+++ b/bp2build/conversion.go
@@ -34,6 +34,12 @@
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()))
diff --git a/bp2build/conversion_test.go b/bp2build/conversion_test.go
index 0cb711c..b696a98 100644
--- a/bp2build/conversion_test.go
+++ b/bp2build/conversion_test.go
@@ -116,6 +116,10 @@
basename: "converted_modules.txt",
},
{
+ dir: "metrics",
+ basename: "converted_modules_path_map.json",
+ },
+ {
dir: "product_config",
basename: "soong_config_variables.bzl",
},
diff --git a/bp2build/metrics.go b/bp2build/metrics.go
index 3a21c34..0b45996 100644
--- a/bp2build/metrics.go
+++ b/bp2build/metrics.go
@@ -9,6 +9,7 @@
"android/soong/android"
"android/soong/shared"
"android/soong/ui/metrics/bp2build_metrics_proto"
+
"github.com/google/blueprint"
)
@@ -38,6 +39,9 @@
// 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 @@
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