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