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
This commit is contained in:
parent
6cf911150a
commit
cbed657b74
|
@ -95,11 +95,38 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule
|
||||||
|
|
||||||
rule = &Rule{}
|
rule = &Rule{}
|
||||||
|
|
||||||
dexpreoptDisabled := contains(global.DisablePreoptModules, module.Name)
|
generateProfile := module.ProfileClassListing != "" && !global.DisableGenerateProfile
|
||||||
|
|
||||||
if contains(global.BootJars, module.Name) {
|
var profile string
|
||||||
// Don't preopt individual boot jars, they will be preopted together
|
if generateProfile {
|
||||||
dexpreoptDisabled = true
|
profile = profileCommand(global, module, rule)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
for _, arch := range module.Archs {
|
||||||
|
imageLocation := module.DexPreoptImageLocation
|
||||||
|
if imageLocation == "" {
|
||||||
|
imageLocation = global.DefaultDexPreoptImageLocation[arch]
|
||||||
|
}
|
||||||
|
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
|
// If OnlyPreoptBootImageAndSystemServer=true and module is not in boot class path skip
|
||||||
|
@ -108,32 +135,10 @@ func GenerateDexpreoptRule(global GlobalConfig, module ModuleConfig) (rule *Rule
|
||||||
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
// or performance. If PreoptExtractedApk is true, we ignore the only preopt boot image options.
|
||||||
if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) &&
|
if global.OnlyPreoptBootImageAndSystemServer && !contains(global.BootJars, module.Name) &&
|
||||||
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
!contains(global.SystemServerJars, module.Name) && !module.PreoptExtractedApk {
|
||||||
dexpreoptDisabled = true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
generateProfile := module.ProfileClassListing != "" && !global.DisableGenerateProfile
|
return false
|
||||||
|
|
||||||
var profile string
|
|
||||||
if generateProfile {
|
|
||||||
profile = profileCommand(global, module, rule)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !dexpreoptDisabled {
|
|
||||||
appImage := (generateProfile || module.ForceCreateAppImage || global.DefaultAppImages) &&
|
|
||||||
!module.NoCreateAppImage
|
|
||||||
|
|
||||||
generateDM := shouldGenerateDM(module, global)
|
|
||||||
|
|
||||||
for _, arch := range module.Archs {
|
|
||||||
imageLocation := module.DexPreoptImageLocation
|
|
||||||
if imageLocation == "" {
|
|
||||||
imageLocation = global.DefaultDexPreoptImageLocation[arch]
|
|
||||||
}
|
|
||||||
dexpreoptCommand(global, module, rule, profile, arch, imageLocation, appImage, generateDM)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rule, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func profileCommand(global GlobalConfig, module ModuleConfig, rule *Rule) string {
|
func profileCommand(global GlobalConfig, module ModuleConfig, rule *Rule) string {
|
||||||
|
@ -445,6 +450,10 @@ func dexpreoptCommand(global GlobalConfig, module ModuleConfig, rule *Rule, prof
|
||||||
func shouldStripDex(module ModuleConfig, global GlobalConfig) bool {
|
func shouldStripDex(module ModuleConfig, global GlobalConfig) bool {
|
||||||
strip := !global.DefaultNoStripping
|
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
|
// 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.
|
// 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) {
|
if !strings.HasPrefix(module.DexLocation, SystemPartition) {
|
||||||
|
|
Loading…
Reference in New Issue