Merge changes Iba57c949,Ief43ff51,Ib1809a4d,I2ab64f36

* changes:
  Store ndkKnownLibs in the config
  Register the kythe singleton on the Context instead of globally
  Store ninja file deps from PackageVarContext in the config
  Store SingletonMakeVarsProviders in the config
This commit is contained in:
Treehugger Robot
2020-11-18 20:00:31 +00:00
committed by Gerrit Code Review
14 changed files with 183 additions and 61 deletions

View File

@@ -88,7 +88,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
})
android.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
ctx.RegisterSingletonType("kythe_extract_all", kytheExtractAllFactory)
}
type Deps struct {
@@ -369,7 +369,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
@@ -939,8 +939,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 {
@@ -1145,8 +1145,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 {
@@ -1766,7 +1766,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))

View File

@@ -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())
}
}
}

View File

@@ -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, " "))

View File

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