Convert JavaInfoProvider to *JavaInfo
Convert JavaInfoProvider to return a *JavaInfo instead of a JavaInfo. This will reduce copying when reading the provider, and also allows JavaInfo to recursively contain a depset of JavaInfos from dependencies. Bug: 308016794 Test: go test ./java/... Flag: EXEMPT refactor Change-Id: Ibf6d9b797f760ad1fe815d59839839fdfad91733
This commit is contained in:
@@ -1348,7 +1348,7 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
a.headerJarFile = classpathFile
|
||||
}
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(a.headerJarFile),
|
||||
ResourceJars: android.PathsIfNonNil(resourceJarFile),
|
||||
TransitiveLibsHeaderJars: a.transitiveLibsHeaderJars,
|
||||
|
44
java/base.go
44
java/base.go
@@ -1235,7 +1235,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
return
|
||||
}
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
||||
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
|
||||
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
|
||||
@@ -1753,7 +1753,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
|
||||
ctx.CheckbuildFile(outputFile)
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
||||
RepackagedHeaderJars: android.PathsIfNonNil(j.repackagedHeaderJarFile),
|
||||
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
|
||||
@@ -1986,23 +1986,24 @@ func (j *providesTransitiveHeaderJars) collectTransitiveHeaderJars(ctx android.M
|
||||
return
|
||||
}
|
||||
|
||||
dep, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
|
||||
tag := ctx.OtherModuleDependencyTag(module)
|
||||
_, isUsesLibDep := tag.(usesLibraryDependencyTag)
|
||||
if tag == libTag || tag == r8LibraryJarTag || isUsesLibDep {
|
||||
directLibs = append(directLibs, dep.HeaderJars...)
|
||||
} else if tag == staticLibTag {
|
||||
directStaticLibs = append(directStaticLibs, dep.HeaderJars...)
|
||||
} else {
|
||||
// Don't propagate transitive libs for other kinds of dependencies.
|
||||
return
|
||||
}
|
||||
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
|
||||
tag := ctx.OtherModuleDependencyTag(module)
|
||||
_, isUsesLibDep := tag.(usesLibraryDependencyTag)
|
||||
if tag == libTag || tag == r8LibraryJarTag || isUsesLibDep {
|
||||
directLibs = append(directLibs, dep.HeaderJars...)
|
||||
} else if tag == staticLibTag {
|
||||
directStaticLibs = append(directStaticLibs, dep.HeaderJars...)
|
||||
} else {
|
||||
// Don't propagate transitive libs for other kinds of dependencies.
|
||||
return
|
||||
}
|
||||
|
||||
if dep.TransitiveLibsHeaderJars != nil {
|
||||
transitiveLibs = append(transitiveLibs, dep.TransitiveLibsHeaderJars)
|
||||
}
|
||||
if dep.TransitiveStaticLibsHeaderJars != nil {
|
||||
transitiveStaticLibs = append(transitiveStaticLibs, dep.TransitiveStaticLibsHeaderJars)
|
||||
if dep.TransitiveLibsHeaderJars != nil {
|
||||
transitiveLibs = append(transitiveLibs, dep.TransitiveLibsHeaderJars)
|
||||
}
|
||||
if dep.TransitiveStaticLibsHeaderJars != nil {
|
||||
transitiveStaticLibs = append(transitiveStaticLibs, dep.TransitiveStaticLibsHeaderJars)
|
||||
}
|
||||
}
|
||||
})
|
||||
j.transitiveLibsHeaderJars = android.NewDepSet(android.POSTORDER, directLibs, transitiveLibs)
|
||||
@@ -2108,9 +2109,10 @@ func (j *Module) collectTransitiveSrcFiles(ctx android.ModuleContext, mine andro
|
||||
ctx.VisitDirectDeps(func(module android.Module) {
|
||||
tag := ctx.OtherModuleDependencyTag(module)
|
||||
if tag == staticLibTag {
|
||||
depInfo, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
|
||||
if depInfo.TransitiveSrcFiles != nil {
|
||||
fromDeps = append(fromDeps, depInfo.TransitiveSrcFiles)
|
||||
if depInfo, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
|
||||
if depInfo.TransitiveSrcFiles != nil {
|
||||
fromDeps = append(fromDeps, depInfo.TransitiveSrcFiles)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@@ -130,7 +130,7 @@ func (d *DeviceHostConverter) GenerateAndroidBuildActions(ctx android.ModuleCont
|
||||
d.combinedHeaderJar = d.headerJars[0]
|
||||
}
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: d.headerJars,
|
||||
ImplementationAndResourcesJars: d.implementationAndResourceJars,
|
||||
ImplementationJars: d.implementationJars,
|
||||
|
@@ -291,8 +291,9 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams)
|
||||
// See b/20667396
|
||||
var proguardRaiseDeps classpath
|
||||
ctx.VisitDirectDepsWithTag(proguardRaiseTag, func(m android.Module) {
|
||||
dep, _ := android.OtherModuleProvider(ctx, m, JavaInfoProvider)
|
||||
proguardRaiseDeps = append(proguardRaiseDeps, dep.RepackagedHeaderJars...)
|
||||
if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
|
||||
proguardRaiseDeps = append(proguardRaiseDeps, dep.RepackagedHeaderJars...)
|
||||
}
|
||||
})
|
||||
|
||||
r8Flags = append(r8Flags, proguardRaiseDeps.FormJavaClassPath("-libraryjars"))
|
||||
|
@@ -98,8 +98,9 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar OptionalDexJ
|
||||
// processing.
|
||||
classesJars := android.Paths{classesJar}
|
||||
ctx.VisitDirectDepsWithTag(hiddenApiAnnotationsTag, func(dep android.Module) {
|
||||
javaInfo, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||
classesJars = append(classesJars, javaInfo.ImplementationJars...)
|
||||
if javaInfo, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
|
||||
classesJars = append(classesJars, javaInfo.ImplementationJars...)
|
||||
}
|
||||
})
|
||||
h.classesJarPaths = classesJars
|
||||
|
||||
|
23
java/java.go
23
java/java.go
@@ -315,14 +315,14 @@ type JavaInfo struct {
|
||||
AconfigIntermediateCacheOutputPaths android.Paths
|
||||
}
|
||||
|
||||
var JavaInfoProvider = blueprint.NewProvider[JavaInfo]()
|
||||
var JavaInfoProvider = blueprint.NewProvider[*JavaInfo]()
|
||||
|
||||
// SyspropPublicStubInfo contains info about the sysprop public stub library that corresponds to
|
||||
// the sysprop implementation library.
|
||||
type SyspropPublicStubInfo struct {
|
||||
// JavaInfo is the JavaInfoProvider of the sysprop public stub library that corresponds to
|
||||
// the sysprop implementation library.
|
||||
JavaInfo JavaInfo
|
||||
JavaInfo *JavaInfo
|
||||
}
|
||||
|
||||
var SyspropPublicStubInfoProvider = blueprint.NewProvider[SyspropPublicStubInfo]()
|
||||
@@ -2249,14 +2249,17 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
srcFilesInfo = append(srcFilesInfo, provider)
|
||||
case libTag:
|
||||
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||
classPaths = append(classPaths, provider.HeaderJars...)
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
|
||||
classPaths = append(classPaths, provider.HeaderJars...)
|
||||
}
|
||||
case bootClasspathTag:
|
||||
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||
bootclassPaths = append(bootclassPaths, provider.HeaderJars...)
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
|
||||
bootclassPaths = append(bootclassPaths, provider.HeaderJars...)
|
||||
}
|
||||
case staticLibTag:
|
||||
provider, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||
staticLibs = append(staticLibs, provider.HeaderJars...)
|
||||
if provider, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
|
||||
staticLibs = append(staticLibs, provider.HeaderJars...)
|
||||
}
|
||||
case systemModulesTag:
|
||||
module := dep.(SystemModulesProvider)
|
||||
systemModulesPaths = append(systemModulesPaths, module.HeaderJars()...)
|
||||
@@ -2358,7 +2361,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
|
||||
ctx.Phony(ctx.ModuleName(), al.stubsJar)
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(al.stubsJar),
|
||||
ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar),
|
||||
ImplementationJars: android.PathsIfNonNil(al.stubsJar),
|
||||
@@ -2787,7 +2790,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
}
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(j.combinedHeaderFile),
|
||||
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
|
||||
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
|
||||
|
@@ -168,9 +168,10 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo
|
||||
|
||||
var transitiveSrcFiles android.Paths
|
||||
for _, module := range allModules {
|
||||
depInfo, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
|
||||
if depInfo.TransitiveSrcFiles != nil {
|
||||
transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...)
|
||||
if depInfo, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
|
||||
if depInfo.TransitiveSrcFiles != nil {
|
||||
transitiveSrcFiles = append(transitiveSrcFiles, depInfo.TransitiveSrcFiles.ToList()...)
|
||||
}
|
||||
}
|
||||
}
|
||||
jarArgs := resourcePathsToJarArgs(transitiveSrcFiles)
|
||||
|
@@ -214,12 +214,13 @@ func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
||||
}
|
||||
|
||||
handleLibDeps := func(dep android.Module, runtimeOnly bool) {
|
||||
m, _ := android.OtherModuleProvider(ctx, dep, JavaInfoProvider)
|
||||
if !runtimeOnly {
|
||||
r.libs = append(r.libs, ctx.OtherModuleName(dep))
|
||||
}
|
||||
if !android.InList(ctx.OtherModuleName(dep), config.FrameworkLibraries) {
|
||||
combinedJarJars = append(combinedJarJars, m.ImplementationAndResourcesJars...)
|
||||
if m, ok := android.OtherModuleProvider(ctx, dep, JavaInfoProvider); ok {
|
||||
combinedJarJars = append(combinedJarJars, m.ImplementationAndResourcesJars...)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -162,8 +162,9 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
|
||||
var jars android.Paths
|
||||
|
||||
ctx.VisitDirectDepsWithTag(systemModulesLibsTag, func(module android.Module) {
|
||||
dep, _ := android.OtherModuleProvider(ctx, module, JavaInfoProvider)
|
||||
jars = append(jars, dep.HeaderJars...)
|
||||
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
|
||||
jars = append(jars, dep.HeaderJars...)
|
||||
}
|
||||
})
|
||||
|
||||
system.headerJars = jars
|
||||
|
Reference in New Issue
Block a user