Merge "Support transitive proguard specs in android_library_import" into main
This commit is contained in:
commit
f875565c7f
3 changed files with 54 additions and 15 deletions
|
@ -1161,11 +1161,17 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
a.rTxt = extractedAARDir.Join(ctx, "R.txt")
|
||||
a.assetsPackage = android.PathForModuleOut(ctx, "assets.zip")
|
||||
a.proguardFlags = extractedAARDir.Join(ctx, "proguard.txt")
|
||||
transitiveProguardFlags, transitiveUnconditionalExportedFlags := collectDepProguardSpecInfo(ctx)
|
||||
android.SetProvider(ctx, ProguardSpecInfoProvider, ProguardSpecInfo{
|
||||
ProguardFlagsFiles: android.NewDepSet[android.Path](
|
||||
android.POSTORDER,
|
||||
android.Paths{a.proguardFlags},
|
||||
transitiveProguardFlags,
|
||||
),
|
||||
UnconditionallyExportedProguardFlags: android.NewDepSet[android.Path](
|
||||
android.POSTORDER,
|
||||
nil,
|
||||
transitiveUnconditionalExportedFlags,
|
||||
),
|
||||
})
|
||||
|
||||
|
|
|
@ -3625,7 +3625,10 @@ func TestExportedProguardFlagFiles(t *testing.T) {
|
|||
android_app {
|
||||
name: "foo",
|
||||
sdk_version: "current",
|
||||
static_libs: ["lib1"],
|
||||
static_libs: [
|
||||
"lib1",
|
||||
"lib3",
|
||||
],
|
||||
}
|
||||
|
||||
android_library {
|
||||
|
@ -3633,22 +3636,49 @@ func TestExportedProguardFlagFiles(t *testing.T) {
|
|||
sdk_version: "current",
|
||||
optimize: {
|
||||
proguard_flags_files: ["lib1proguard.cfg"],
|
||||
},
|
||||
static_libs: ["lib2"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "lib2",
|
||||
sdk_version: "current",
|
||||
optimize: {
|
||||
proguard_flags_files: ["lib2proguard.cfg"],
|
||||
}
|
||||
}
|
||||
|
||||
android_library_import {
|
||||
name: "lib3",
|
||||
sdk_version: "current",
|
||||
aars: ["lib3.aar"],
|
||||
static_libs: ["lib4"],
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "lib4",
|
||||
sdk_version: "current",
|
||||
optimize: {
|
||||
proguard_flags_files: ["lib4proguard.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
|
||||
}
|
||||
}
|
||||
r8 := m.Rule("java.r8")
|
||||
implicits := r8.Implicits.RelativeToTop().Strings()
|
||||
android.AssertStringListContains(t, "r8 implicits", implicits, "lib1proguard.cfg")
|
||||
android.AssertStringListContains(t, "r8 implicits", implicits, "lib2proguard.cfg")
|
||||
android.AssertStringListContains(t, "r8 implicits", implicits, "lib4proguard.cfg")
|
||||
android.AssertStringListContains(t, "r8 implicits", implicits, "out/soong/.intermediates/lib3/android_common/aar/proguard.txt")
|
||||
|
||||
if !hasLib1Proguard {
|
||||
t.Errorf("App does not use library proguard config")
|
||||
}
|
||||
flags := r8.Args["r8Flags"]
|
||||
android.AssertStringDoesContain(t, "r8 flags", flags, "-include lib1proguard.cfg")
|
||||
android.AssertStringDoesContain(t, "r8 flags", flags, "-include lib2proguard.cfg")
|
||||
android.AssertStringDoesContain(t, "r8 flags", flags, "-include lib4proguard.cfg")
|
||||
android.AssertStringDoesContain(t, "r8 flags", flags, "-include out/soong/.intermediates/lib3/android_common/aar/proguard.txt")
|
||||
}
|
||||
|
||||
func TestTargetSdkVersionManifestFixer(t *testing.T) {
|
||||
|
|
11
java/base.go
11
java/base.go
|
@ -1757,10 +1757,7 @@ func (j *Module) useCompose() bool {
|
|||
return android.InList("androidx.compose.runtime_runtime", j.properties.Static_libs)
|
||||
}
|
||||
|
||||
func (j *Module) collectProguardSpecInfo(ctx android.ModuleContext) ProguardSpecInfo {
|
||||
transitiveUnconditionalExportedFlags := []*android.DepSet[android.Path]{}
|
||||
transitiveProguardFlags := []*android.DepSet[android.Path]{}
|
||||
|
||||
func collectDepProguardSpecInfo(ctx android.ModuleContext) (transitiveProguardFlags, transitiveUnconditionalExportedFlags []*android.DepSet[android.Path]) {
|
||||
ctx.VisitDirectDeps(func(m android.Module) {
|
||||
depProguardInfo, _ := android.OtherModuleProvider(ctx, m, ProguardSpecInfoProvider)
|
||||
depTag := ctx.OtherModuleDependencyTag(m)
|
||||
|
@ -1775,6 +1772,12 @@ func (j *Module) collectProguardSpecInfo(ctx android.ModuleContext) ProguardSpec
|
|||
}
|
||||
})
|
||||
|
||||
return transitiveProguardFlags, transitiveUnconditionalExportedFlags
|
||||
}
|
||||
|
||||
func (j *Module) collectProguardSpecInfo(ctx android.ModuleContext) ProguardSpecInfo {
|
||||
transitiveProguardFlags, transitiveUnconditionalExportedFlags := collectDepProguardSpecInfo(ctx)
|
||||
|
||||
directUnconditionalExportedFlags := android.Paths{}
|
||||
proguardFlagsForThisModule := android.PathsForModuleSrc(ctx, j.dexProperties.Optimize.Proguard_flags_files)
|
||||
exportUnconditionally := proptools.Bool(j.dexProperties.Optimize.Export_proguard_flags_files)
|
||||
|
|
Loading…
Reference in a new issue