Merge "Include proguard flag files from transitive java_library deps"

This commit is contained in:
Treehugger Robot
2022-12-17 01:39:08 +00:00
committed by Gerrit Code Review
4 changed files with 87 additions and 13 deletions

View File

@@ -294,6 +294,11 @@ type UsesLibraryDependency interface {
ClassLoaderContexts() dexpreopt.ClassLoaderContextMap
}
// Provides transitive Proguard flag files to downstream DEX jars.
type LibraryDependency interface {
ExportedProguardFlagFiles() android.Paths
}
// TODO(jungjw): Move this to kythe.go once it's created.
type xref interface {
XrefJavaFiles() android.Paths
@@ -596,9 +601,17 @@ func normalizeJavaVersion(ctx android.BaseModuleContext, javaVersion string) jav
type Library struct {
Module
exportedProguardFlagFiles android.Paths
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.Paths)
}
var _ LibraryDependency = (*Library)(nil)
func (j *Library) ExportedProguardFlagFiles() android.Paths {
return j.exportedProguardFlagFiles
}
var _ android.ApexModule = (*Library)(nil)
// Provides access to the list of permitted packages from apex boot jars.
@@ -694,6 +707,15 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
j.installFile = ctx.InstallFile(installDir, j.Stem()+".jar", j.outputFile, extraInstallDeps...)
}
j.exportedProguardFlagFiles = append(j.exportedProguardFlagFiles,
android.PathsForModuleSrc(ctx, j.dexProperties.Optimize.Proguard_flags_files)...)
ctx.VisitDirectDeps(func(m android.Module) {
if lib, ok := m.(LibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
j.exportedProguardFlagFiles = append(j.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
}
})
j.exportedProguardFlagFiles = android.FirstUniquePaths(j.exportedProguardFlagFiles)
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {