Fix false pos in bp2build-prog due to prebulits

The prebuilt_ prefix was removed before writing converted modules, which
causes false positives when a prebuilt and from source module exist with
the same name but only one has been converted

Test: b run //build/bazel/scripts/bp2build_progress:bp2build_progress \
    -- report -m core-lambda-stubs-for-system-modules
Change-Id: Id00099780fb6af9fffcf745b509116a66bac8756
This commit is contained in:
Liz Kammer 2023-08-25 17:42:42 -04:00
parent 1725b20d14
commit 32c634bca9
3 changed files with 19 additions and 2 deletions

View file

@ -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 {

View file

@ -134,7 +134,7 @@ func TestCreateBazelFiles_Bp2Build_CreatesDefaultFiles(t *testing.T) {
},
{
dir: "metrics",
basename: "converted_modules.txt",
basename: "converted_modules.json",
},
{
dir: "metrics",

View file

@ -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