Merge "Fix binaries and symlinks for prefer32" am: 9fdbbb3c54
am: d9005822c7
Change-Id: I3b5da4409d6504a5f4d90ae76abceb04b6d28fd1
This commit is contained in:
@@ -274,6 +274,7 @@ func ArchMutator(mctx BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var moduleTargets []Target
|
var moduleTargets []Target
|
||||||
|
primaryModules := make(map[int]bool)
|
||||||
|
|
||||||
for _, class := range osClasses {
|
for _, class := range osClasses {
|
||||||
targets := mctx.AConfig().Targets[class]
|
targets := mctx.AConfig().Targets[class]
|
||||||
@@ -293,11 +294,18 @@ func ArchMutator(mctx BottomUpMutatorContext) {
|
|||||||
if multilib == "" {
|
if multilib == "" {
|
||||||
multilib = module.base().commonProperties.Default_multilib
|
multilib = module.base().commonProperties.Default_multilib
|
||||||
}
|
}
|
||||||
targets, err := decodeMultilib(multilib, targets)
|
prefer32 := false
|
||||||
|
if class == Device {
|
||||||
|
prefer32 = mctx.AConfig().DevicePrefer32BitExecutables()
|
||||||
|
}
|
||||||
|
targets, err := decodeMultilib(multilib, targets, prefer32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mctx.ModuleErrorf("%s", err.Error())
|
mctx.ModuleErrorf("%s", err.Error())
|
||||||
}
|
}
|
||||||
moduleTargets = append(moduleTargets, targets...)
|
if len(targets) > 0 {
|
||||||
|
primaryModules[len(moduleTargets)] = true
|
||||||
|
moduleTargets = append(moduleTargets, targets...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(moduleTargets) == 0 {
|
if len(moduleTargets) == 0 {
|
||||||
@@ -313,7 +321,7 @@ func ArchMutator(mctx BottomUpMutatorContext) {
|
|||||||
|
|
||||||
modules := mctx.CreateVariations(targetNames...)
|
modules := mctx.CreateVariations(targetNames...)
|
||||||
for i, m := range modules {
|
for i, m := range modules {
|
||||||
m.(Module).base().SetTarget(moduleTargets[i])
|
m.(Module).base().SetTarget(moduleTargets[i], primaryModules[i])
|
||||||
m.(Module).base().setArchProperties(mctx)
|
m.(Module).base().setArchProperties(mctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -915,15 +923,26 @@ func filterMultilibTargets(targets []Target, multilib string) []Target {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use the module multilib setting to select one or more targets from a target list
|
// Use the module multilib setting to select one or more targets from a target list
|
||||||
func decodeMultilib(multilib string, targets []Target) ([]Target, error) {
|
func decodeMultilib(multilib string, targets []Target, prefer32 bool) ([]Target, error) {
|
||||||
buildTargets := []Target{}
|
buildTargets := []Target{}
|
||||||
|
if multilib == "first" {
|
||||||
|
if prefer32 {
|
||||||
|
multilib = "prefer32"
|
||||||
|
} else {
|
||||||
|
multilib = "prefer64"
|
||||||
|
}
|
||||||
|
}
|
||||||
switch multilib {
|
switch multilib {
|
||||||
case "common":
|
case "common":
|
||||||
buildTargets = append(buildTargets, commonTarget)
|
buildTargets = append(buildTargets, commonTarget)
|
||||||
case "both":
|
case "both":
|
||||||
buildTargets = append(buildTargets, targets...)
|
if prefer32 {
|
||||||
case "first":
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib32")...)
|
||||||
buildTargets = append(buildTargets, targets[0])
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib64")...)
|
||||||
|
} else {
|
||||||
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib64")...)
|
||||||
|
buildTargets = append(buildTargets, filterMultilibTargets(targets, "lib32")...)
|
||||||
|
}
|
||||||
case "32":
|
case "32":
|
||||||
buildTargets = filterMultilibTargets(targets, "lib32")
|
buildTargets = filterMultilibTargets(targets, "lib32")
|
||||||
case "64":
|
case "64":
|
||||||
@@ -933,6 +952,11 @@ func decodeMultilib(multilib string, targets []Target) ([]Target, error) {
|
|||||||
if len(buildTargets) == 0 {
|
if len(buildTargets) == 0 {
|
||||||
buildTargets = filterMultilibTargets(targets, "lib64")
|
buildTargets = filterMultilibTargets(targets, "lib64")
|
||||||
}
|
}
|
||||||
|
case "prefer64":
|
||||||
|
buildTargets = filterMultilibTargets(targets, "lib64")
|
||||||
|
if len(buildTargets) == 0 {
|
||||||
|
buildTargets = filterMultilibTargets(targets, "lib32")
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", "64", or "prefer32" found %q`,
|
return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", "64", or "prefer32" found %q`,
|
||||||
multilib)
|
multilib)
|
||||||
|
@@ -57,6 +57,7 @@ type ModuleBuildParams struct {
|
|||||||
|
|
||||||
type androidBaseContext interface {
|
type androidBaseContext interface {
|
||||||
Target() Target
|
Target() Target
|
||||||
|
TargetPrimary() bool
|
||||||
Arch() Arch
|
Arch() Arch
|
||||||
Os() OsType
|
Os() OsType
|
||||||
Host() bool
|
Host() bool
|
||||||
@@ -145,7 +146,8 @@ type commonProperties struct {
|
|||||||
Required []string
|
Required []string
|
||||||
|
|
||||||
// Set by TargetMutator
|
// Set by TargetMutator
|
||||||
CompileTarget Target `blueprint:"mutated"`
|
CompileTarget Target `blueprint:"mutated"`
|
||||||
|
CompilePrimary bool `blueprint:"mutated"`
|
||||||
|
|
||||||
// Set by InitAndroidModule
|
// Set by InitAndroidModule
|
||||||
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
|
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
|
||||||
@@ -282,14 +284,19 @@ func (a *ModuleBase) base() *ModuleBase {
|
|||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ModuleBase) SetTarget(target Target) {
|
func (a *ModuleBase) SetTarget(target Target, primary bool) {
|
||||||
a.commonProperties.CompileTarget = target
|
a.commonProperties.CompileTarget = target
|
||||||
|
a.commonProperties.CompilePrimary = primary
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ModuleBase) Target() Target {
|
func (a *ModuleBase) Target() Target {
|
||||||
return a.commonProperties.CompileTarget
|
return a.commonProperties.CompileTarget
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *ModuleBase) TargetPrimary() bool {
|
||||||
|
return a.commonProperties.CompilePrimary
|
||||||
|
}
|
||||||
|
|
||||||
func (a *ModuleBase) Os() OsType {
|
func (a *ModuleBase) Os() OsType {
|
||||||
return a.Target().Os
|
return a.Target().Os
|
||||||
}
|
}
|
||||||
@@ -420,8 +427,9 @@ func (a *ModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
|
|||||||
|
|
||||||
func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
|
func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
|
||||||
return androidBaseContextImpl{
|
return androidBaseContextImpl{
|
||||||
target: a.commonProperties.CompileTarget,
|
target: a.commonProperties.CompileTarget,
|
||||||
config: ctx.Config().(Config),
|
targetPrimary: a.commonProperties.CompilePrimary,
|
||||||
|
config: ctx.Config().(Config),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,9 +462,10 @@ func (a *ModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type androidBaseContextImpl struct {
|
type androidBaseContextImpl struct {
|
||||||
target Target
|
target Target
|
||||||
debug bool
|
targetPrimary bool
|
||||||
config Config
|
debug bool
|
||||||
|
config Config
|
||||||
}
|
}
|
||||||
|
|
||||||
type androidModuleContext struct {
|
type androidModuleContext struct {
|
||||||
@@ -536,6 +545,10 @@ func (a *androidBaseContextImpl) Target() Target {
|
|||||||
return a.target
|
return a.target
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *androidBaseContextImpl) TargetPrimary() bool {
|
||||||
|
return a.targetPrimary
|
||||||
|
}
|
||||||
|
|
||||||
func (a *androidBaseContextImpl) Arch() Arch {
|
func (a *androidBaseContextImpl) Arch() Arch {
|
||||||
return a.target.Arch
|
return a.target.Arch
|
||||||
}
|
}
|
||||||
|
@@ -170,11 +170,7 @@ func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) {
|
|||||||
if binary.Properties.Stem == "" && binary.Properties.Suffix == "" {
|
if binary.Properties.Stem == "" && binary.Properties.Suffix == "" {
|
||||||
ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix")
|
ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix")
|
||||||
}
|
}
|
||||||
prefer32 := false
|
if ctx.TargetPrimary() {
|
||||||
if ctx.Device() {
|
|
||||||
prefer32 = ctx.AConfig().DevicePrefer32BitExecutables()
|
|
||||||
}
|
|
||||||
if ctx.PrimaryArch() != prefer32 {
|
|
||||||
binary.baseInstaller.Properties.Symlinks = append(binary.baseInstaller.Properties.Symlinks,
|
binary.baseInstaller.Properties.Symlinks = append(binary.baseInstaller.Properties.Symlinks,
|
||||||
ctx.ModuleName())
|
ctx.ModuleName())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user