Change init process of bp2buildAllowlist so the Soong plugin of bp2build allowlist can hookup properly.

Bug: 216442475
Test: m nothing
Change-Id: I47d768e09aa290e23fb846404686dcf26c8caf41
This commit is contained in:
Wei Li
2022-05-12 23:37:53 -07:00
parent 94361dc903
commit d7736ec1b1
3 changed files with 55 additions and 14 deletions

View File

@@ -300,25 +300,31 @@ func (a bp2BuildConversionAllowlist) SetMixedBuildsDisabledList(mixedBuildsDisab
return a
}
var bp2buildAllowlist = NewBp2BuildAllowlist().
SetDefaultConfig(allowlists.Bp2buildDefaultConfig).
SetKeepExistingBuildFile(allowlists.Bp2buildKeepExistingBuildFile).
SetModuleAlwaysConvertList(allowlists.Bp2buildModuleAlwaysConvertList).
SetModuleTypeAlwaysConvertList(allowlists.Bp2buildModuleTypeAlwaysConvertList).
SetModuleDoNotConvertList(allowlists.Bp2buildModuleDoNotConvertList).
SetCcLibraryStaticOnlyList(allowlists.Bp2buildCcLibraryStaticOnlyList).
SetMixedBuildsDisabledList(allowlists.MixedBuildsDisabledList)
var bp2BuildAllowListKey = NewOnceKey("Bp2BuildAllowlist")
var bp2buildAllowlist OncePer
func getBp2BuildAllowList() bp2BuildConversionAllowlist {
return bp2buildAllowlist.Once(bp2BuildAllowListKey, func() interface{} {
return NewBp2BuildAllowlist().SetDefaultConfig(allowlists.Bp2buildDefaultConfig).
SetKeepExistingBuildFile(allowlists.Bp2buildKeepExistingBuildFile).
SetModuleAlwaysConvertList(allowlists.Bp2buildModuleAlwaysConvertList).
SetModuleTypeAlwaysConvertList(allowlists.Bp2buildModuleTypeAlwaysConvertList).
SetModuleDoNotConvertList(allowlists.Bp2buildModuleDoNotConvertList).
SetCcLibraryStaticOnlyList(allowlists.Bp2buildCcLibraryStaticOnlyList).
SetMixedBuildsDisabledList(allowlists.MixedBuildsDisabledList)
}).(bp2BuildConversionAllowlist)
}
// GenerateCcLibraryStaticOnly returns whether a cc_library module should only
// generate a static version of itself based on the current global configuration.
func GenerateCcLibraryStaticOnly(moduleName string) bool {
return bp2buildAllowlist.ccLibraryStaticOnly[moduleName]
return getBp2BuildAllowList().ccLibraryStaticOnly[moduleName]
}
// ShouldKeepExistingBuildFileForDir returns whether an existing BUILD file should be
// added to the build symlink forest based on the current global configuration.
func ShouldKeepExistingBuildFileForDir(dir string) bool {
return shouldKeepExistingBuildFileForDir(bp2buildAllowlist, dir)
return shouldKeepExistingBuildFileForDir(getBp2BuildAllowList(), dir)
}
func shouldKeepExistingBuildFileForDir(allowlist bp2BuildConversionAllowlist, dir string) bool {
@@ -371,7 +377,7 @@ func mixedBuildPossible(ctx ModuleContext) bool {
// variants of a cc_library.
return false
}
return !bp2buildAllowlist.mixedBuildsDisabled[ctx.Module().Name()]
return !getBp2BuildAllowList().mixedBuildsDisabled[ctx.Module().Name()]
}
// ConvertedToBazel returns whether this module has been converted (with bp2build or manually) to Bazel.