Merge changes I2b182cd3,Ibf6d9b79 into main
* changes: Split jarjarIfNecessary out of compileJavaHeader Convert JavaInfoProvider to *JavaInfo
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,
|
||||
|
130
java/base.go
130
java/base.go
@@ -1228,14 +1228,17 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
ctx.ModuleErrorf("headers_only is enabled but Turbine is disabled.")
|
||||
}
|
||||
|
||||
_, j.headerJarFile, _ =
|
||||
j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName,
|
||||
extraCombinedJars)
|
||||
_, combinedHeaderJarFile := j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName,
|
||||
extraCombinedJars)
|
||||
|
||||
combinedHeaderJarFile = j.jarjarIfNecessary(ctx, combinedHeaderJarFile, jarName, "turbine")
|
||||
combinedHeaderJarFile = j.repackageFlagsIfNecessary(ctx, combinedHeaderJarFile, jarName, "repackage-turbine")
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
j.headerJarFile = combinedHeaderJarFile
|
||||
|
||||
android.SetProvider(ctx, JavaInfoProvider, JavaInfo{
|
||||
android.SetProvider(ctx, JavaInfoProvider, &JavaInfo{
|
||||
HeaderJars: android.PathsIfNonNil(j.headerJarFile),
|
||||
TransitiveLibsHeaderJars: j.transitiveLibsHeaderJars,
|
||||
TransitiveStaticLibsHeaderJars: j.transitiveStaticLibsHeaderJars,
|
||||
@@ -1347,11 +1350,12 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
// with sharding enabled. See: b/77284273.
|
||||
}
|
||||
extraJars := append(slices.Clone(kotlinHeaderJars), extraCombinedJars...)
|
||||
headerJarFileWithoutDepsOrJarjar, j.headerJarFile, j.repackagedHeaderJarFile =
|
||||
var combinedHeaderJarFile android.Path
|
||||
headerJarFileWithoutDepsOrJarjar, combinedHeaderJarFile =
|
||||
j.compileJavaHeader(ctx, uniqueJavaFiles, srcJars, deps, flags, jarName, extraJars)
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
|
||||
j.headerJarFile = j.jarjarIfNecessary(ctx, combinedHeaderJarFile, jarName, "turbine")
|
||||
j.repackagedHeaderJarFile = j.repackageFlagsIfNecessary(ctx, j.headerJarFile, jarName, "turbine")
|
||||
}
|
||||
if len(uniqueJavaFiles) > 0 || len(srcJars) > 0 {
|
||||
hasErrorproneableFiles := false
|
||||
@@ -1548,22 +1552,17 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
|
||||
}
|
||||
|
||||
// jarjar implementation jar if necessary
|
||||
if j.expandJarjarRules != nil {
|
||||
// Transform classes.jar into classes-jarjar.jar
|
||||
jarjarFile := android.PathForModuleOut(ctx, "jarjar", jarName)
|
||||
TransformJarJar(ctx, jarjarFile, outputFile, j.expandJarjarRules)
|
||||
outputFile = jarjarFile
|
||||
jarjarFile := j.jarjarIfNecessary(ctx, outputFile, jarName, "")
|
||||
outputFile = jarjarFile
|
||||
|
||||
// jarjar resource jar if necessary
|
||||
if j.resourceJar != nil {
|
||||
resourceJarJarFile := android.PathForModuleOut(ctx, "res-jarjar", jarName)
|
||||
TransformJarJar(ctx, resourceJarJarFile, j.resourceJar, j.expandJarjarRules)
|
||||
j.resourceJar = resourceJarJarFile
|
||||
}
|
||||
// jarjar resource jar if necessary
|
||||
if j.resourceJar != nil {
|
||||
resourceJarJarFile := j.jarjarIfNecessary(ctx, j.resourceJar, jarName, "resource")
|
||||
j.resourceJar = resourceJarJarFile
|
||||
}
|
||||
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
if ctx.Failed() {
|
||||
return
|
||||
}
|
||||
|
||||
// Check package restrictions if necessary.
|
||||
@@ -1753,7 +1752,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,
|
||||
@@ -1896,16 +1895,13 @@ func CheckKotlincFlags(ctx android.ModuleContext, flags []string) {
|
||||
|
||||
func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars android.Paths,
|
||||
deps deps, flags javaBuilderFlags, jarName string,
|
||||
extraJars android.Paths) (headerJar, jarjarAndDepsHeaderJar, jarjarAndDepsRepackagedHeaderJar android.Path) {
|
||||
extraJars android.Paths) (headerJar android.Path, combinedHeaderJar android.Path) {
|
||||
|
||||
var jars android.Paths
|
||||
if len(srcFiles) > 0 || len(srcJars) > 0 {
|
||||
// Compile java sources into turbine.jar.
|
||||
turbineJar := android.PathForModuleOut(ctx, "turbine", jarName)
|
||||
TransformJavaToHeaderClasses(ctx, turbineJar, srcFiles, srcJars, flags)
|
||||
if ctx.Failed() {
|
||||
return nil, nil, nil
|
||||
}
|
||||
jars = append(jars, turbineJar)
|
||||
headerJar = turbineJar
|
||||
}
|
||||
@@ -1918,33 +1914,11 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
|
||||
|
||||
// we cannot skip the combine step for now if there is only one jar
|
||||
// since we have to strip META-INF/TRANSITIVE dir from turbine.jar
|
||||
combinedJar := android.PathForModuleOut(ctx, "turbine-combined", jarName)
|
||||
TransformJarsToJar(ctx, combinedJar, "for turbine", jars, android.OptionalPath{},
|
||||
combinedHeaderJarOutputPath := android.PathForModuleOut(ctx, "turbine-combined", jarName)
|
||||
TransformJarsToJar(ctx, combinedHeaderJarOutputPath, "for turbine", jars, android.OptionalPath{},
|
||||
false, nil, []string{"META-INF/TRANSITIVE"})
|
||||
jarjarAndDepsHeaderJar = combinedJar
|
||||
|
||||
if j.expandJarjarRules != nil {
|
||||
// Transform classes.jar into classes-jarjar.jar
|
||||
jarjarFile := android.PathForModuleOut(ctx, "turbine-jarjar", jarName)
|
||||
TransformJarJar(ctx, jarjarFile, jarjarAndDepsHeaderJar, j.expandJarjarRules)
|
||||
jarjarAndDepsHeaderJar = jarjarFile
|
||||
if ctx.Failed() {
|
||||
return nil, nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
if j.repackageJarjarRules != nil {
|
||||
repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-turbine-jarjar", jarName)
|
||||
TransformJarJar(ctx, repackagedJarjarFile, jarjarAndDepsHeaderJar, j.repackageJarjarRules)
|
||||
jarjarAndDepsRepackagedHeaderJar = repackagedJarjarFile
|
||||
if ctx.Failed() {
|
||||
return nil, nil, nil
|
||||
}
|
||||
} else {
|
||||
jarjarAndDepsRepackagedHeaderJar = jarjarAndDepsHeaderJar
|
||||
}
|
||||
|
||||
return headerJar, jarjarAndDepsHeaderJar, jarjarAndDepsRepackagedHeaderJar
|
||||
return headerJar, combinedHeaderJarOutputPath
|
||||
}
|
||||
|
||||
func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
|
||||
@@ -1986,23 +1960,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 +2083,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)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -2730,11 +2706,21 @@ func (j *Module) repackageFlagsIfNecessary(ctx android.ModuleContext, infile and
|
||||
if j.repackageJarjarRules == nil {
|
||||
return infile
|
||||
}
|
||||
repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-jarjar", info+jarName)
|
||||
repackagedJarjarFile := android.PathForModuleOut(ctx, "repackaged-jarjar", info, jarName)
|
||||
TransformJarJar(ctx, repackagedJarjarFile, infile, j.repackageJarjarRules)
|
||||
return repackagedJarjarFile
|
||||
}
|
||||
|
||||
func (j *Module) jarjarIfNecessary(ctx android.ModuleContext, infile android.Path, jarName, info string) android.Path {
|
||||
if j.expandJarjarRules == nil {
|
||||
return infile
|
||||
}
|
||||
jarjarFile := android.PathForModuleOut(ctx, "jarjar", info, jarName)
|
||||
TransformJarJar(ctx, jarjarFile, infile, j.expandJarjarRules)
|
||||
return jarjarFile
|
||||
|
||||
}
|
||||
|
||||
func addPlugins(deps *deps, pluginJars android.Paths, pluginClasses ...string) {
|
||||
deps.processorPath = append(deps.processorPath, pluginJars...)
|
||||
deps.processorClasses = append(deps.processorClasses, pluginClasses...)
|
||||
|
@@ -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