Provide reason for unconverted bp2build modules
This also changes the expectation of ConvertWithBp2build. Each implementation must either create one or more Bazel target modules, or mark the module as unconvertible (with a specific reason). Manually verified no runtime hit in AOSP In AOSP, the metrics file size increases from 252K to 1.6M This changes some effective module counts in bp2build metrics: - Removes "package" modules from the module count list in metrics, as these will not be converted like regular modules. - Counts Handcrafted modules as being "unconverted", as bp2build is not responsible for them. Bug: 285631638 Test: Verified generated BUILD.bazel files are bit-for-bit identical with this change Test: Manually verified one case of each implemented reasonType Change-Id: I308dd451d8f28379b15671dae9f931bd0446f5c1
This commit is contained in:
@@ -78,7 +78,7 @@ type Bp2buildTestCase struct {
|
||||
ModuleTypeUnderTestFactory android.ModuleFactory
|
||||
// Text to add to the toplevel, root Android.bp file. If Dir is not set, all
|
||||
// ExpectedBazelTargets are assumed to be generated by this file.
|
||||
Blueprint string
|
||||
Blueprint string
|
||||
// ExpectedBazelTargets compares the BazelTargets generated in `Dir` (if not empty).
|
||||
// Otherwise, it checks the BazelTargets generated by `Blueprint` in the root directory.
|
||||
ExpectedBazelTargets []string
|
||||
@@ -146,6 +146,10 @@ func runBp2BuildTestCaseWithSetup(t *testing.T, extraPreparer android.FixturePre
|
||||
})
|
||||
}
|
||||
ctx.RegisterBp2BuildConfig(bp2buildConfig)
|
||||
// This setting is added to bp2build invocations. It prevents bp2build
|
||||
// from cloning modules to their original state after mutators run. This
|
||||
// would lose some data intentionally set by these mutators.
|
||||
ctx.SkipCloneModulesAfterMutators = true
|
||||
}),
|
||||
android.FixtureModifyEnv(func(env map[string]string) {
|
||||
if tc.UnconvertedDepsMode == errorModulesUnconvertedDeps {
|
||||
@@ -210,7 +214,11 @@ func (b *bazelTestRunner) PostParseProcessor(result android.CustomTestResult) {
|
||||
return
|
||||
}
|
||||
|
||||
codegenCtx := NewCodegenContext(config, ctx.Context, Bp2Build, "")
|
||||
codegenMode := Bp2Build
|
||||
if ctx.Config().BuildMode == android.ApiBp2build {
|
||||
codegenMode = ApiBp2build
|
||||
}
|
||||
codegenCtx := NewCodegenContext(config, ctx.Context, codegenMode, "")
|
||||
res, errs := GenerateBazelTargets(codegenCtx, false)
|
||||
if bazelResult.CollateErrs(errs) {
|
||||
return
|
||||
|
Reference in New Issue
Block a user