Export proguard_flags_files from android_librarys
If an android_library has a proguard flag file, that file should also be used when compiling apps with the library. Fixes: 171425221 Test: New unit test in app_test.go, and manually
This commit is contained in:
@@ -536,6 +536,8 @@ func (a *AndroidLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
|
||||
ctx.CheckbuildFile(a.aarFile)
|
||||
}
|
||||
|
||||
a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles,
|
||||
android.PathsForModuleSrc(ctx, a.dexProperties.Optimize.Proguard_flags_files)...)
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
if lib, ok := m.(AndroidLibraryDependency); ok && ctx.OtherModuleDependencyTag(m) == staticLibTag {
|
||||
a.exportedProguardFlagFiles = append(a.exportedProguardFlagFiles, lib.ExportedProguardFlagFiles()...)
|
||||
|
@@ -3491,3 +3491,34 @@ func TestEnforceRRO_propagatesToDependencies(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestExportedProguardFlagFiles(t *testing.T) {
|
||||
ctx, _ := testJava(t, `
|
||||
android_app {
|
||||
name: "foo",
|
||||
sdk_version: "current",
|
||||
static_libs: ["lib1"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "lib1",
|
||||
sdk_version: "current",
|
||||
optimize: {
|
||||
proguard_flags_files: ["lib1proguard.cfg"],
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
m := ctx.ModuleForTests("foo", "android_common")
|
||||
hasLib1Proguard := false
|
||||
for _, s := range m.Rule("java.r8").Implicits.Strings() {
|
||||
if s == "lib1proguard.cfg" {
|
||||
hasLib1Proguard = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !hasLib1Proguard {
|
||||
t.Errorf("App does not use library proguard config")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user