aboutsummaryrefslogtreecommitdiff
path: root/dexpreopt
diff options
context:
space:
mode:
Diffstat (limited to 'dexpreopt')
-rw-r--r--dexpreopt/config.go9
-rw-r--r--dexpreopt/dexpreopt.go8
-rw-r--r--dexpreopt/testing.go14
3 files changed, 31 insertions, 0 deletions
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 609a29c2d..0cc3bd63b 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -475,7 +475,16 @@ func RegisterToolDeps(ctx android.BottomUpMutatorContext) {
ctx.AddFarVariationDependencies(v, Dex2oatDepTag, dex2oatBin)
}
+func IsDex2oatNeeded(ctx android.PathContext) bool {
+ global := GetGlobalConfig(ctx)
+ return !global.DisablePreopt || !global.DisablePreoptBootImages
+}
+
func dex2oatPathFromDep(ctx android.ModuleContext) android.Path {
+ if !IsDex2oatNeeded(ctx) {
+ return nil
+ }
+
dex2oatBin := dex2oatModuleName(ctx.Config())
// Find the right dex2oat module, trying to follow PrebuiltDepTag from source
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index a590c72a5..2b38793ff 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -100,11 +100,19 @@ func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongC
return rule, nil
}
+// If dexpreopt is applicable to the module, returns whether dexpreopt is disabled. Otherwise, the
+// behavior is undefined.
+// When it returns true, dexpreopt artifacts will not be generated, but profile will still be
+// generated if profile-guided compilation is requested.
func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *ModuleConfig) bool {
if ctx.Config().UnbundledBuild() {
return true
}
+ if global.DisablePreopt {
+ return true
+ }
+
if contains(global.DisablePreoptModules, module.Name) {
return true
}
diff --git a/dexpreopt/testing.go b/dexpreopt/testing.go
index 47ae494e3..6ed0736f7 100644
--- a/dexpreopt/testing.go
+++ b/dexpreopt/testing.go
@@ -174,3 +174,17 @@ func FixtureDisableGenerateProfile(disable bool) android.FixturePreparer {
dexpreoptConfig.DisableGenerateProfile = disable
})
}
+
+// FixtureDisableDexpreoptBootImages sets the DisablePreoptBootImages property in the global config.
+func FixtureDisableDexpreoptBootImages(disable bool) android.FixturePreparer {
+ return FixtureModifyGlobalConfig(func(_ android.PathContext, dexpreoptConfig *GlobalConfig) {
+ dexpreoptConfig.DisablePreoptBootImages = disable
+ })
+}
+
+// FixtureDisableDexpreopt sets the DisablePreopt property in the global config.
+func FixtureDisableDexpreopt(disable bool) android.FixturePreparer {
+ return FixtureModifyGlobalConfig(func(_ android.PathContext, dexpreoptConfig *GlobalConfig) {
+ dexpreoptConfig.DisablePreopt = disable
+ })
+}