Store ndkKnownLibs in the config
Storing ndkKnownLibs prevents multiple tests from running in parallel as one may be writing to the list while another is reading from it. Store it in the config so each test has its own copy. Test: go test -race ./apex Change-Id: Iba57c9494012c9e0ae9e5ffaa63b9b2bd2c77492
This commit is contained in:
12
cc/cc.go
12
cc/cc.go
@@ -368,7 +368,7 @@ type ModuleContextIntf interface {
|
||||
useSdk() bool
|
||||
sdkVersion() string
|
||||
useVndk() bool
|
||||
isNdk() bool
|
||||
isNdk(config android.Config) bool
|
||||
isLlndk(config android.Config) bool
|
||||
isLlndkPublic(config android.Config) bool
|
||||
isVndkPrivate(config android.Config) bool
|
||||
@@ -938,8 +938,8 @@ func (c *Module) isCoverageVariant() bool {
|
||||
return c.coverage.Properties.IsCoverageVariant
|
||||
}
|
||||
|
||||
func (c *Module) IsNdk() bool {
|
||||
return inList(c.BaseModuleName(), ndkKnownLibs)
|
||||
func (c *Module) IsNdk(config android.Config) bool {
|
||||
return inList(c.BaseModuleName(), *getNDKKnownLibs(config))
|
||||
}
|
||||
|
||||
func (c *Module) isLlndk(config android.Config) bool {
|
||||
@@ -1140,8 +1140,8 @@ func (ctx *moduleContextImpl) useVndk() bool {
|
||||
return ctx.mod.UseVndk()
|
||||
}
|
||||
|
||||
func (ctx *moduleContextImpl) isNdk() bool {
|
||||
return ctx.mod.IsNdk()
|
||||
func (ctx *moduleContextImpl) isNdk(config android.Config) bool {
|
||||
return ctx.mod.IsNdk(config)
|
||||
}
|
||||
|
||||
func (ctx *moduleContextImpl) isLlndk(config android.Config) bool {
|
||||
@@ -1761,7 +1761,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
||||
for _, entry := range list {
|
||||
// strip #version suffix out
|
||||
name, _ := StubsLibNameAndVersion(entry)
|
||||
if ctx.useSdk() && inList(name, ndkKnownLibs) {
|
||||
if ctx.useSdk() && inList(name, *getNDKKnownLibs(ctx.Config())) {
|
||||
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
|
||||
} else if ctx.useVndk() {
|
||||
nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry))
|
||||
|
@@ -567,7 +567,7 @@ func (library *libraryDecorator) classifySourceAbiDump(ctx ModuleContext) string
|
||||
return ""
|
||||
}
|
||||
// Return NDK if the library is both NDK and LLNDK.
|
||||
if ctx.isNdk() {
|
||||
if ctx.isNdk(ctx.Config()) {
|
||||
return "NDK"
|
||||
}
|
||||
if ctx.isLlndkPublic(ctx.Config()) {
|
||||
@@ -1099,7 +1099,7 @@ func (library *libraryDecorator) coverageOutputFilePath() android.OptionalPath {
|
||||
|
||||
func getRefAbiDumpFile(ctx ModuleContext, vndkVersion, fileName string) android.Path {
|
||||
// The logic must be consistent with classifySourceAbiDump.
|
||||
isNdk := ctx.isNdk()
|
||||
isNdk := ctx.isNdk(ctx.Config())
|
||||
isLlndkOrVndk := ctx.isLlndkPublic(ctx.Config()) || (ctx.useVndk() && ctx.isVndk())
|
||||
|
||||
refAbiDumpTextFile := android.PathForVndkRefAbiDump(ctx, vndkVersion, fileName, isNdk, isLlndkOrVndk, false)
|
||||
@@ -1153,7 +1153,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
|
||||
library.sAbiDiff = SourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
|
||||
refAbiDumpFile, fileName, exportedHeaderFlags,
|
||||
Bool(library.Properties.Header_abi_checker.Check_all_apis),
|
||||
ctx.isLlndk(ctx.Config()), ctx.isNdk(), ctx.isVndkExt())
|
||||
ctx.isLlndk(ctx.Config()), ctx.isNdk(ctx.Config()), ctx.isVndkExt())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -171,6 +171,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
||||
ctx.StrictRaw("SRC_HEADERS", strings.Join(includes, " "))
|
||||
ctx.StrictRaw("SRC_SYSTEM_HEADERS", strings.Join(systemIncludes, " "))
|
||||
|
||||
ndkKnownLibs := *getNDKKnownLibs(ctx.Config())
|
||||
sort.Strings(ndkKnownLibs)
|
||||
ctx.Strict("NDK_KNOWN_LIBS", strings.Join(ndkKnownLibs, " "))
|
||||
|
||||
|
@@ -45,8 +45,7 @@ var (
|
||||
|
||||
ndkLibrarySuffix = ".ndk"
|
||||
|
||||
// Added as a variation dependency via depsMutator.
|
||||
ndkKnownLibs = []string{}
|
||||
ndkKnownLibsKey = android.NewOnceKey("ndkKnownLibsKey")
|
||||
// protects ndkKnownLibs writes during parallel BeginMutator.
|
||||
ndkKnownLibsLock sync.Mutex
|
||||
)
|
||||
@@ -158,6 +157,12 @@ func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func getNDKKnownLibs(config android.Config) *[]string {
|
||||
return config.Once(ndkKnownLibsKey, func() interface{} {
|
||||
return &[]string{}
|
||||
}).(*[]string)
|
||||
}
|
||||
|
||||
func (c *stubDecorator) compilerInit(ctx BaseModuleContext) {
|
||||
c.baseCompiler.compilerInit(ctx)
|
||||
|
||||
@@ -168,12 +173,13 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) {
|
||||
|
||||
ndkKnownLibsLock.Lock()
|
||||
defer ndkKnownLibsLock.Unlock()
|
||||
for _, lib := range ndkKnownLibs {
|
||||
ndkKnownLibs := getNDKKnownLibs(ctx.Config())
|
||||
for _, lib := range *ndkKnownLibs {
|
||||
if lib == name {
|
||||
return
|
||||
}
|
||||
}
|
||||
ndkKnownLibs = append(ndkKnownLibs, name)
|
||||
*ndkKnownLibs = append(*ndkKnownLibs, name)
|
||||
}
|
||||
|
||||
func addStubLibraryCompilerFlags(flags Flags) Flags {
|
||||
|
Reference in New Issue
Block a user