diff --git a/android/arch.go b/android/arch.go index 57899cd53..95f880353 100644 --- a/android/arch.go +++ b/android/arch.go @@ -295,46 +295,47 @@ func archMutator(mctx BottomUpMutatorContext) { return } - if !module.base().ArchSpecific() { + base := module.base() + + if !base.ArchSpecific() { return } - osClasses := module.base().OsClassSupported() + osClasses := base.OsClassSupported() var moduleTargets []Target primaryModules := make(map[int]bool) for _, class := range osClasses { - targets := mctx.Config().Targets[class] - if len(targets) == 0 { + classTargets := mctx.Config().Targets[class] + if len(classTargets) == 0 { continue } - var multilib string - switch class { - case Device: - multilib = String(module.base().commonProperties.Target.Android.Compile_multilib) - case Host, HostCross: - multilib = String(module.base().commonProperties.Target.Host.Compile_multilib) - } - if multilib == "" { - multilib = String(module.base().commonProperties.Compile_multilib) - } - if multilib == "" { - multilib = module.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 - } // only the primary arch in the recovery partition if module.InstallInRecovery() { - targets = []Target{mctx.Config().Targets[Device][0]} + classTargets = []Target{mctx.Config().Targets[Device][0]} } - targets, err := decodeMultilib(multilib, targets, prefer32) + + var multilib string + switch class { + case Device: + multilib = String(base.commonProperties.Target.Android.Compile_multilib) + case Host, HostCross: + multilib = String(base.commonProperties.Target.Host.Compile_multilib) + } + if multilib == "" { + multilib = String(base.commonProperties.Compile_multilib) + } + if multilib == "" { + multilib = base.commonProperties.Default_multilib + } + + 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()) } @@ -345,7 +346,7 @@ func archMutator(mctx BottomUpMutatorContext) { } if len(moduleTargets) == 0 { - module.base().commonProperties.Enabled = boolPtr(false) + base.commonProperties.Enabled = boolPtr(false) return } diff --git a/android/module.go b/android/module.go index 92b11ed0d..01766b447 100644 --- a/android/module.go +++ b/android/module.go @@ -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 { diff --git a/cc/cc.go b/cc/cc.go index d31a38adc..d04485d71 100644 --- a/cc/cc.go +++ b/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) diff --git a/java/aar.go b/java/aar.go index 29f5597a9..35fb96f78 100644 --- a/java/aar.go +++ b/java/aar.go @@ -359,7 +359,7 @@ func AndroidLibraryFactory() android.Module { module.androidLibraryProperties.BuildAAR = true - android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + InitJavaModule(module, android.DeviceSupported) return module } @@ -382,6 +382,7 @@ type AARImportProperties struct { type AARImport struct { android.ModuleBase + android.DefaultableModuleBase prebuilt android.Prebuilt properties AARImportProperties @@ -555,6 +556,6 @@ func AARImportFactory() android.Module { module.AddProperties(&module.properties) android.InitPrebuiltModule(module, &module.properties.Aars) - android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) + InitJavaModule(module, android.DeviceSupported) return module } diff --git a/java/app.go b/java/app.go index f8bef1ce8..dc5296d17 100644 --- a/java/app.go +++ b/java/app.go @@ -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 } diff --git a/java/java.go b/java/java.go index 8b354d91d..b4b8feb23 100644 --- a/java/java.go +++ b/java/java.go @@ -1493,7 +1493,6 @@ func TestFactory() android.Module { module.Module.properties.Installable = proptools.BoolPtr(true) InitJavaModule(module, android.HostAndDeviceSupported) - android.InitDefaultableModule(module) return module } @@ -1508,7 +1507,6 @@ func TestHostFactory() android.Module { module.Module.properties.Installable = proptools.BoolPtr(true) InitJavaModule(module, android.HostSupported) - android.InitDefaultableModule(module) return module } @@ -1624,6 +1622,7 @@ type ImportProperties struct { type Import struct { android.ModuleBase + android.DefaultableModuleBase prebuilt android.Prebuilt properties ImportProperties @@ -1752,7 +1751,7 @@ func ImportFactory() android.Module { module.AddProperties(&module.properties) android.InitPrebuiltModule(module, &module.properties.Jars) - android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) + InitJavaModule(module, android.HostAndDeviceSupported) return module } @@ -1762,7 +1761,7 @@ func ImportFactoryHost() android.Module { module.AddProperties(&module.properties) android.InitPrebuiltModule(module, &module.properties.Jars) - android.InitAndroidArchModule(module, android.HostSupported, android.MultilibCommon) + InitJavaModule(module, android.HostSupported) return module } @@ -1792,6 +1791,13 @@ func DefaultsFactory(props ...interface{}) android.Module { &CompilerProperties{}, &CompilerDeviceProperties{}, &android.ProtoProperties{}, + &aaptProperties{}, + &androidLibraryProperties{}, + &appProperties{}, + &appTestProperties{}, + &ImportProperties{}, + &AARImportProperties{}, + &sdkLibraryProperties{}, ) android.InitDefaultsModule(module) diff --git a/java/sdk_library.go b/java/sdk_library.go index 3e6908bde..a8c3b118a 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -691,7 +691,6 @@ func sdkLibraryFactory() android.Module { module := &sdkLibrary{} module.AddProperties(&module.properties) module.AddProperties(&module.deviceProperties) - android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) - android.InitDefaultableModule(module) + InitJavaModule(module, android.DeviceSupported) return module }