Bp2build support for app R8-related fields
Bug: 293304784 Test: CI Change-Id: I0aefa57f968cb41e50d7c1d29b2d8a1480655355
This commit is contained in:
38
java/app.go
38
java/app.go
@@ -29,6 +29,7 @@ import (
|
||||
"android/soong/bazel"
|
||||
"android/soong/cc"
|
||||
"android/soong/dexpreopt"
|
||||
"android/soong/genrule"
|
||||
"android/soong/tradefed"
|
||||
)
|
||||
|
||||
@@ -1614,6 +1615,8 @@ type bazelAndroidAppAttributes struct {
|
||||
Certificate bazel.LabelAttribute
|
||||
Certificate_name bazel.StringAttribute
|
||||
Manifest_values *manifestValueAttribute
|
||||
Optimize *bool
|
||||
Proguard_specs bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
// ConvertWithBp2build is used to convert android_app to Bazel.
|
||||
@@ -1665,6 +1668,41 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
Manifest_values: manifestValues,
|
||||
}
|
||||
|
||||
if !BoolDefault(a.dexProperties.Optimize.Enabled, true) {
|
||||
appAttrs.Optimize = proptools.BoolPtr(false)
|
||||
} else {
|
||||
handCraftedFlags := ""
|
||||
if Bool(a.dexProperties.Optimize.Ignore_warnings) {
|
||||
handCraftedFlags += "-ignorewarning "
|
||||
}
|
||||
if !Bool(a.dexProperties.Optimize.Shrink) {
|
||||
handCraftedFlags += "-dontshrink "
|
||||
}
|
||||
if !Bool(a.dexProperties.Optimize.Optimize) {
|
||||
handCraftedFlags += "-dontoptimize "
|
||||
}
|
||||
if !Bool(a.dexProperties.Optimize.Obfuscate) {
|
||||
handCraftedFlags += "-dontobfuscate "
|
||||
}
|
||||
appAttrs.Proguard_specs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, a.dexProperties.Optimize.Proguard_flags_files))
|
||||
if handCraftedFlags != "" {
|
||||
generatedFlagFileRuleName := a.Name() + "_proguard_flags"
|
||||
ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "genrule",
|
||||
}, android.CommonAttributes{
|
||||
Name: generatedFlagFileRuleName,
|
||||
SkipData: proptools.BoolPtr(true),
|
||||
}, &genrule.BazelGenruleAttributes{
|
||||
Outs: []string{a.Name() + "_proguard.flags"},
|
||||
Cmd: bazel.StringAttribute{
|
||||
Value: proptools.StringPtr("echo " + handCraftedFlags + "> $(OUTS)"),
|
||||
},
|
||||
})
|
||||
appAttrs.Proguard_specs.Add(bazel.MakeLabelAttribute(":" + generatedFlagFileRuleName))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "android_binary",
|
||||
Bzl_load_location: "//build/bazel/rules/android:android_binary.bzl",
|
||||
|
Reference in New Issue
Block a user