Make prefer32 a lambda
prefer32 needs to be set differently for app and native modules. Make it use lambda provided by the module type instead of trying to make archMutator figure it out. Test: m checkbuild Change-Id: Ibf8af35fdd3e1721725539d1f5452f4439d2125c
This commit is contained in:
@@ -329,14 +329,12 @@ func archMutator(mctx BottomUpMutatorContext) {
|
||||
if multilib == "" {
|
||||
multilib = base.commonProperties.Default_multilib
|
||||
}
|
||||
var prefer32 bool
|
||||
switch class {
|
||||
case Device:
|
||||
prefer32 = mctx.Config().DevicePrefer32BitExecutables()
|
||||
case HostCross:
|
||||
// Windows builds always prefer 32-bit
|
||||
prefer32 = true
|
||||
|
||||
prefer32 := false
|
||||
if base.prefer32 != nil {
|
||||
prefer32 = base.prefer32(mctx, base, class)
|
||||
}
|
||||
|
||||
targets, err := decodeMultilib(multilib, classTargets, prefer32)
|
||||
if err != nil {
|
||||
mctx.ModuleErrorf("%s", err.Error())
|
||||
|
@@ -442,6 +442,8 @@ type ModuleBase struct {
|
||||
|
||||
// For tests
|
||||
buildParams []BuildParams
|
||||
|
||||
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
|
||||
}
|
||||
|
||||
func (a *ModuleBase) AddProperties(props ...interface{}) {
|
||||
@@ -456,6 +458,10 @@ func (a *ModuleBase) BuildParamsForTests() []BuildParams {
|
||||
return a.buildParams
|
||||
}
|
||||
|
||||
func (a *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
|
||||
a.prefer32 = prefer32
|
||||
}
|
||||
|
||||
// Name returns the name of the module. It may be overridden by individual module types, for
|
||||
// example prebuilts will prepend prebuilt_ to the name.
|
||||
func (a *ModuleBase) Name() string {
|
||||
|
11
cc/cc.go
11
cc/cc.go
@@ -406,6 +406,17 @@ func (c *Module) Init() android.Module {
|
||||
c.AddProperties(feature.props()...)
|
||||
}
|
||||
|
||||
c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
|
||||
switch class {
|
||||
case android.Device:
|
||||
return ctx.Config().DevicePrefer32BitExecutables()
|
||||
case android.HostCross:
|
||||
// Windows builds always prefer 32-bit
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
})
|
||||
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
||||
|
||||
android.InitDefaultableModule(c)
|
||||
|
@@ -208,6 +208,10 @@ func AndroidAppFactory() android.Module {
|
||||
&module.aaptProperties,
|
||||
&module.appProperties)
|
||||
|
||||
module.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
|
||||
return class == android.Device && ctx.Config().DevicePrefer32BitApps()
|
||||
})
|
||||
|
||||
InitJavaModule(module, android.DeviceSupported)
|
||||
return module
|
||||
}
|
||||
|
Reference in New Issue
Block a user