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:
parent
94361dc903
commit
d7736ec1b1
3 changed files with 55 additions and 14 deletions
|
@ -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.
|
||||
|
|
|
@ -14,11 +14,12 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"android/soong/android/allowlists"
|
||||
"android/soong/bazel"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"android/soong/android/allowlists"
|
||||
"android/soong/bazel"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
@ -386,3 +387,37 @@ func TestBp2BuildAllowlist(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBp2buildAllowList(t *testing.T) {
|
||||
allowlist := getBp2BuildAllowList()
|
||||
for k, v := range allowlists.Bp2buildDefaultConfig {
|
||||
if allowlist.defaultConfig[k] != v {
|
||||
t.Errorf("bp2build default config of %s: expected: %v, got: %v", k, v, allowlist.defaultConfig[k])
|
||||
}
|
||||
}
|
||||
for k, v := range allowlists.Bp2buildKeepExistingBuildFile {
|
||||
if allowlist.keepExistingBuildFile[k] != v {
|
||||
t.Errorf("bp2build keep existing build file of %s: expected: %v, got: %v", k, v, allowlist.keepExistingBuildFile[k])
|
||||
}
|
||||
}
|
||||
for _, k := range allowlists.Bp2buildModuleTypeAlwaysConvertList {
|
||||
if !allowlist.moduleTypeAlwaysConvert[k] {
|
||||
t.Errorf("bp2build module type always convert of %s: expected: true, got: %v", k, allowlist.moduleTypeAlwaysConvert[k])
|
||||
}
|
||||
}
|
||||
for _, k := range allowlists.Bp2buildModuleDoNotConvertList {
|
||||
if !allowlist.moduleDoNotConvert[k] {
|
||||
t.Errorf("bp2build module do not convert of %s: expected: true, got: %v", k, allowlist.moduleDoNotConvert[k])
|
||||
}
|
||||
}
|
||||
for _, k := range allowlists.Bp2buildCcLibraryStaticOnlyList {
|
||||
if !allowlist.ccLibraryStaticOnly[k] {
|
||||
t.Errorf("bp2build cc library static only of %s: expected: true, got: %v", k, allowlist.ccLibraryStaticOnly[k])
|
||||
}
|
||||
}
|
||||
for _, k := range allowlists.MixedBuildsDisabledList {
|
||||
if !allowlist.mixedBuildsDisabled[k] {
|
||||
t.Errorf("bp2build mix build disabled of %s: expected: true, got: %v", k, allowlist.mixedBuildsDisabled[k])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -558,7 +558,7 @@ func NewConfig(moduleListFile string, runGoTests bool, outDir, soongOutDir strin
|
|||
}
|
||||
|
||||
config.BazelContext, err = NewBazelContext(config)
|
||||
config.bp2buildPackageConfig = bp2buildAllowlist
|
||||
config.bp2buildPackageConfig = getBp2BuildAllowList()
|
||||
|
||||
return Config{config}, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue