diff options
author | Colin Cross <ccross@android.com> | 2019-01-08 17:38:37 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-01-09 19:47:47 +0000 |
commit | cbed657b74343a56a95884f03f7c8cb2c0b2b621 (patch) | |
tree | 05b37f8bce0f1257929180dca766a0041b4cc885 /dexpreopt | |
parent | 6cf911150a523724864316ee90e5251ce3a98ce3 (diff) | |
download | build_soong-cbed657b74343a56a95884f03f7c8cb2c0b2b621.tar.gz build_soong-cbed657b74343a56a95884f03f7c8cb2c0b2b621.tar.bz2 build_soong-cbed657b74343a56a95884f03f7c8cb2c0b2b621.zip |
Don't strip when dexpreopt is disabled
If dexpreopt is disabled for a module then classes.dex must not be
stripped.
Bug: 121377197
Test: m WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY=true
Change-Id: Icfa48804cf02291874ac6623c9b9297821ac8ce6
Diffstat (limited to 'dexpreopt')
-rw-r--r-- | dexpreopt/dexpreopt.go | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go index 4ad039f4..8f453036 100644 --- a/dexpreopt/dexpreopt.go +++ b/dexpreopt/dexpreopt.go @@ -95,22 +95,6 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule rule = &Rule{} - dexpreoptDisabled := contains(global.DisablePreoptModules, module.Name) - - if contains(global.BootJars, module.Name) { - // Don't preopt individual boot jars, they will be preopted together - dexpreoptDisabled = true - } - - // If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip - // Also preopt system server jars since selinux prevents system server from loading anything from - // /data. If we don't do this they will need to be extracted which is not favorable for RAM usage - // or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options. - if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) && - !contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk { - dexpreoptDisabled = true - } - generateProfile := module.ProfileClassListing != "" && !global.DisableGenerateProfile var profile string @@ -118,24 +102,45 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule profile = profileCommand(global, module, rule) } - if !dexpreoptDisabled { - appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) && - !module.NoCreateAppImage + if !dexpreoptDisabled(global, module) { + // Don't preopt individual boot jars, they will be preopted together. + // This check is outside dexpreoptDisabled because they still need to be stripped. + if !contains(global.BootJars, module.Name) { + appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) && + !module.NoCreateAppImage - generateDM := shouldGenerateDM(module, global) + generateDM := shouldGenerateDM(module, global) - for _, arch := range module.Archs { - imageLocation := module.DexPreoptImageLocation - if imageLocation == "" { - imageLocation = global.DefaultDexPreoptImageLocation[arch] + for _, arch := range module.Archs { + imageLocation := module.DexPreoptImageLocation + if imageLocation == "" { + imageLocation = global.DefaultDexPreoptImageLocation[arch] + } + dexpreoptCommand(global, module, rule, profile, arch, imageLocation, appImage, generateDM) } - dexpreoptCommand(global, module, rule, profile, arch, imageLocation, appImage, generateDM) } } return rule, nil } +func dexpreoptDisabled(global GlobalConfig, module ModuleConfig) bool { + if contains(global.DisablePreoptModules, module.Name) { + return true + } + + // If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip + // Also preopt system server jars since selinux prevents system server from loading anything from + // /data. If we don't do this they will need to be extracted which is not favorable for RAM usage + // or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options. + if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) && + !contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk { + return true + } + + return false +} + func profileCommand(global GlobalConfig, module ModuleConfig, rule *Rule) string { profilePath := filepath.Join(filepath.Dir(module.BuildPath), "profile.prof") profileInstalledPath := module.DexLocation + ".prof" @@ -445,6 +450,10 @@ func dexpreoptCommand(global GlobalConfig, module ModuleConfig, rule *Rule, prof func shouldStripDex(module ModuleConfig, global GlobalConfig) bool { strip := !global.DefaultNoStripping + if dexpreoptDisabled(global, module) { + strip = false + } + // Don't strip modules that are not on the system partition in case the oat/vdex version in system ROM // doesn't match the one in other partitions. It needs to be able to fall back to the APK for that case. if !strings.HasPrefix(module.DexLocation, SystemPartition) { |