aboutsummaryrefslogtreecommitdiff
path: root/dexpreopt
diff options
context:
space:
mode:
authorJiakai Zhang <jiakaiz@google.com>2023-05-08 16:28:38 +0000
committerJiakai Zhang <jiakaiz@google.com>2023-05-08 21:29:23 +0100
commitcf61e3c59133227894ac7d72091b48451a3e6761 (patch)
tree351deadb2df3cdeb59739d48bda259a55ea7af61 /dexpreopt
parentbc698cd28aa2ee17af208bfd56f003347116ddb0 (diff)
Revert^2 "Generate app profiles even if dexpreopt is disabled."
Revert submission 2580631-revert-2574032-XXTWCJDTDQ Reason for revert: Fixed build breakages Reverted changes: /q/submissionid:2580631-revert-2574032-XXTWCJDTDQ Bug: 280440941 Test: lunch aosp_cf_riscv64_minidroid-userdebug && m UNSAFE_DISABLE_HIDDENAPI_FLAGS=true dist Test: Disable dex2oat on host (to simulate macOS) and build Change-Id: I6090b4b74cedb6d129fcbeef58d075c8ccdcc4e2
Diffstat (limited to 'dexpreopt')
-rw-r--r--dexpreopt/dexpreopt.go8
-rw-r--r--dexpreopt/testing.go7
2 files changed, 15 insertions, 0 deletions
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 b3dd3cca2..6ed0736f7 100644
--- a/dexpreopt/testing.go
+++ b/dexpreopt/testing.go
@@ -181,3 +181,10 @@ func FixtureDisableDexpreoptBootImages(disable bool) android.FixturePreparer {
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
+ })
+}