Merge "Revert "Include proguard flag files from transitive java_library deps""
This commit is contained in:
commit
ed8b52ca27
4 changed files with 13 additions and 87 deletions
22
java/aar.go
22
java/aar.go
|
@ -29,8 +29,8 @@ import (
|
|||
)
|
||||
|
||||
type AndroidLibraryDependency interface {
|
||||
LibraryDependency
|
||||
ExportPackage() android.Path
|
||||
ExportedProguardFlagFiles() android.Paths
|
||||
ExportedRRODirs() []rroDir
|
||||
ExportedStaticPackages() android.Paths
|
||||
ExportedManifests() android.Paths
|
||||
|
@ -498,7 +498,8 @@ type AndroidLibrary struct {
|
|||
|
||||
aarFile android.WritablePath
|
||||
|
||||
exportedStaticPackages android.Paths
|
||||
exportedProguardFlagFiles android.Paths
|
||||
exportedStaticPackages android.Paths
|
||||
}
|
||||
|
||||
var _ android.OutputFileProducer = (*AndroidLibrary)(nil)
|
||||
|
@ -513,6 +514,10 @@ func (a *AndroidLibrary) OutputFiles(tag string) (android.Paths, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func (a *AndroidLibrary) ExportedProguardFlagFiles() android.Paths {
|
||||
return a.exportedProguardFlagFiles
|
||||
}
|
||||
|
||||
func (a *AndroidLibrary) ExportedStaticPackages() android.Paths {
|
||||
return a.exportedStaticPackages
|
||||
}
|
||||
|
@ -561,16 +566,13 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
|||
a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles,
|
||||
android.PathsForModuleSrc(ctx, a.dexProperties.Optimize.Proguard_flags_files)...)
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
if ctx.OtherModuleDependencyTag(m) == staticLibTag {
|
||||
if lib, ok := m.(LibraryDependency); ok {
|
||||
a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
|
||||
}
|
||||
if alib, ok := m.(AndroidLibraryDependency); ok {
|
||||
a.exportedStaticPackages = append(a.exportedStaticPackages, alib.ExportPackage())
|
||||
a.exportedStaticPackages = append(a.exportedStaticPackages, alib.ExportedStaticPackages()...)
|
||||
}
|
||||
if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
|
||||
a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
|
||||
a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportPackage())
|
||||
a.exportedStaticPackages = append(a.exportedStaticPackages, lib.ExportedStaticPackages()...)
|
||||
}
|
||||
})
|
||||
|
||||
a.exportedProguardFlagFiles = android.FirstUniquePaths(a.exportedProguardFlagFiles)
|
||||
a.exportedStaticPackages = android.FirstUniquePaths(a.exportedStaticPackages)
|
||||
|
||||
|
|
|
@ -457,7 +457,7 @@ func (a *AndroidApp) aaptBuildActions(ctx android.ModuleContext) {
|
|||
func (a *AndroidApp) proguardBuildActions(ctx android.ModuleContext) {
|
||||
var staticLibProguardFlagFiles android.Paths
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
if lib, ok := m.(LibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
|
||||
if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
|
||||
staticLibProguardFlagFiles = append(staticLibProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -155,57 +155,3 @@ func TestD8(t *testing.T) {
|
|||
android.AssertStringDoesNotContain(t, "expected no static_lib header jar in foo javac classpath",
|
||||
fooD8.Args["d8Flags"], staticLibHeader.String())
|
||||
}
|
||||
|
||||
func TestProguardFlagsInheritance(t *testing.T) {
|
||||
result := PrepareForTestWithJavaDefaultModulesWithoutFakeDex2oatd.RunTestWithBp(t, `
|
||||
android_app {
|
||||
name: "app",
|
||||
static_libs: [
|
||||
"primary_android_lib",
|
||||
"primary_lib",
|
||||
],
|
||||
platform_apis: true,
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "primary_lib",
|
||||
optimize: {
|
||||
proguard_flags_files: ["primary.flags"],
|
||||
},
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "primary_android_lib",
|
||||
static_libs: ["secondary_lib"],
|
||||
optimize: {
|
||||
proguard_flags_files: ["primary_android.flags"],
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "secondary_lib",
|
||||
static_libs: ["tertiary_lib"],
|
||||
optimize: {
|
||||
proguard_flags_files: ["secondary.flags"],
|
||||
},
|
||||
}
|
||||
|
||||
java_library {
|
||||
name: "tertiary_lib",
|
||||
optimize: {
|
||||
proguard_flags_files: ["tertiary.flags"],
|
||||
},
|
||||
}
|
||||
`)
|
||||
|
||||
app := result.ModuleForTests("app", "android_common")
|
||||
appR8 := app.Rule("r8")
|
||||
android.AssertStringDoesContain(t, "expected primary_lib's proguard flags from direct dep",
|
||||
appR8.Args["r8Flags"], "primary.flags")
|
||||
android.AssertStringDoesContain(t, "expected primary_android_lib's proguard flags from direct dep",
|
||||
appR8.Args["r8Flags"], "primary_android.flags")
|
||||
android.AssertStringDoesContain(t, "expected secondary_lib's proguard flags from inherited dep",
|
||||
appR8.Args["r8Flags"], "secondary.flags")
|
||||
android.AssertStringDoesContain(t, "expected tertiary_lib's proguard flags from inherited dep",
|
||||
appR8.Args["r8Flags"], "tertiary.flags")
|
||||
}
|
||||
|
|
22
java/java.go
22
java/java.go
|
@ -294,11 +294,6 @@ 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
|
||||
|
@ -601,17 +596,9 @@ 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.
|
||||
|
@ -707,15 +694,6 @@ 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) {
|
||||
|
|
Loading…
Reference in a new issue