Only get dexpreopt config for device modules

Calling dexpreopt.GetGlobalConfig can return errors, move the checks
that don't depend on dexpreopt.GetGlobalConfig first to avoid
breaking all modules when the global config is invalid, for example
in a partial branch that is missing the BootProfileImages file.

Bug: 207813628
Test: tradefed branch builds
Change-Id: Id1689de3f1ef986a41a60622cb357edb9d323b8a
This commit is contained in:
Colin Cross
2021-12-01 10:34:14 -08:00
parent 9579f4c05d
commit 38310bb4ac

View File

@@ -122,13 +122,7 @@ func moduleName(ctx android.BaseModuleContext) string {
}
func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
global := dexpreopt.GetGlobalConfig(ctx)
if global.DisablePreopt {
return true
}
if inList(moduleName(ctx), global.DisablePreoptModules) {
if !ctx.Device() {
return true
}
@@ -144,7 +138,17 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
return true
}
if ctx.Host() {
if !android.IsModulePreferred(ctx.Module()) {
return true
}
global := dexpreopt.GetGlobalConfig(ctx)
if global.DisablePreopt {
return true
}
if inList(moduleName(ctx), global.DisablePreoptModules) {
return true
}
@@ -161,10 +165,6 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool {
}
}
if !android.IsModulePreferred(ctx.Module()) {
return true
}
// TODO: contains no java code
return false