Make dexpreopt properties configurable
Spurred by ag/27778860
Test: m nothing --no-skip-soong-tests
Change-Id: I0e48144172eee1c589f46875cd94e3aa19d43873
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 4734357..63a8634 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -147,25 +147,25 @@
type DexpreoptProperties struct {
Dex_preopt struct {
// If false, prevent dexpreopting. Defaults to true.
- Enabled *bool
+ Enabled proptools.Configurable[bool] `android:"replace_instead_of_append"`
// If true, generate an app image (.art file) for this module.
- App_image *bool
+ App_image proptools.Configurable[bool] `android:"replace_instead_of_append"`
// If true, use a checked-in profile to guide optimization. Defaults to false unless
// a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR
// that matches the name of this module, in which case it is defaulted to true.
- Profile_guided *bool
+ Profile_guided proptools.Configurable[bool] `android:"replace_instead_of_append"`
// If set, provides the path to profile relative to the Android.bp file. If not set,
// defaults to searching for a file that matches the name of this module in the default
// profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found.
- Profile *string `android:"path"`
+ Profile proptools.Configurable[string] `android:"path,replace_instead_of_append"`
// If set to true, r8/d8 will use `profile` as input to generate a new profile that matches
// the optimized dex.
// The new profile will be subsequently used as the profile to dexpreopt the dex file.
- Enable_profile_rewriting *bool
+ Enable_profile_rewriting proptools.Configurable[bool] `android:"replace_instead_of_append"`
}
Dex_preopt_result struct {
@@ -244,7 +244,7 @@
return true
}
- if !BoolDefault(d.dexpreoptProperties.Dex_preopt.Enabled, true) {
+ if !d.dexpreoptProperties.Dex_preopt.Enabled.GetOrDefault(ctx, true) {
return true
}
@@ -433,12 +433,12 @@
if d.inputProfilePathOnHost != nil {
profileClassListing = android.OptionalPathForPath(d.inputProfilePathOnHost)
- } else if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) && !forPrebuiltApex(ctx) {
+ } else if d.dexpreoptProperties.Dex_preopt.Profile_guided.GetOrDefault(ctx, true) && !forPrebuiltApex(ctx) {
// If enable_profile_rewriting is set, use the rewritten profile instead of the checked-in profile
- if d.EnableProfileRewriting() {
+ if d.EnableProfileRewriting(ctx) {
profileClassListing = android.OptionalPathForPath(d.GetRewrittenProfile())
profileIsTextListing = true
- } else if profile := d.GetProfile(); profile != "" {
+ } else if profile := d.GetProfile(ctx); profile != "" {
// If dex_preopt.profile_guided is not set, default it based on the existence of the
// dexprepot.profile option or the profile class listing.
profileClassListing = android.OptionalPathForPath(
@@ -458,6 +458,8 @@
// Use the dexJar to create a unique scope for each
dexJarStem := strings.TrimSuffix(dexJarFile.Base(), dexJarFile.Ext())
+ appImage := d.dexpreoptProperties.Dex_preopt.App_image.Get(ctx)
+
// Full dexpreopt config, used to create dexpreopt build rules.
dexpreoptConfig := &dexpreopt.ModuleConfig{
Name: libName,
@@ -486,8 +488,8 @@
PreoptBootClassPathDexFiles: dexFiles.Paths(),
PreoptBootClassPathDexLocations: dexLocations,
- NoCreateAppImage: !BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, true),
- ForceCreateAppImage: BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, false),
+ NoCreateAppImage: !appImage.GetOrDefault(true),
+ ForceCreateAppImage: appImage.GetOrDefault(false),
PresignedPrebuilt: d.isPresignedPrebuilt,
}
@@ -657,16 +659,16 @@
d.shouldDisableDexpreopt = true
}
-func (d *dexpreopter) EnableProfileRewriting() bool {
- return proptools.Bool(d.dexpreoptProperties.Dex_preopt.Enable_profile_rewriting)
+func (d *dexpreopter) EnableProfileRewriting(ctx android.BaseModuleContext) bool {
+ return d.dexpreoptProperties.Dex_preopt.Enable_profile_rewriting.GetOrDefault(ctx, false)
}
-func (d *dexpreopter) GetProfile() string {
- return proptools.String(d.dexpreoptProperties.Dex_preopt.Profile)
+func (d *dexpreopter) GetProfile(ctx android.BaseModuleContext) string {
+ return d.dexpreoptProperties.Dex_preopt.Profile.GetOrDefault(ctx, "")
}
-func (d *dexpreopter) GetProfileGuided() bool {
- return proptools.Bool(d.dexpreoptProperties.Dex_preopt.Profile_guided)
+func (d *dexpreopter) GetProfileGuided(ctx android.BaseModuleContext) bool {
+ return d.dexpreoptProperties.Dex_preopt.Profile_guided.GetOrDefault(ctx, false)
}
func (d *dexpreopter) GetRewrittenProfile() android.Path {