Merge "Add method to determine variations from a Target"
This commit is contained in:
@@ -199,19 +199,19 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
||||
switch amod.Os().Class {
|
||||
case Host:
|
||||
// Make cannot identify LOCAL_MODULE_HOST_ARCH:= common.
|
||||
if archStr != "common" {
|
||||
if amod.Arch().ArchType != Common {
|
||||
a.SetString("LOCAL_MODULE_HOST_ARCH", archStr)
|
||||
}
|
||||
host = true
|
||||
case HostCross:
|
||||
// Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
|
||||
if archStr != "common" {
|
||||
if amod.Arch().ArchType != Common {
|
||||
a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
|
||||
}
|
||||
host = true
|
||||
case Device:
|
||||
// Make cannot identify LOCAL_MODULE_TARGET_ARCH:= common.
|
||||
if archStr != "common" {
|
||||
if amod.Arch().ArchType != Common {
|
||||
if amod.Target().NativeBridge {
|
||||
hostArchStr := amod.Target().NativeBridgeHostArchName
|
||||
if hostArchStr != "" {
|
||||
|
@@ -22,9 +22,12 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
const COMMON_VARIANT = "common"
|
||||
|
||||
var (
|
||||
archTypeList []ArchType
|
||||
|
||||
@@ -36,7 +39,7 @@ var (
|
||||
X86_64 = newArch("x86_64", "lib64")
|
||||
|
||||
Common = ArchType{
|
||||
Name: "common",
|
||||
Name: COMMON_VARIANT,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -702,11 +705,23 @@ type Target struct {
|
||||
}
|
||||
|
||||
func (target Target) String() string {
|
||||
variant := ""
|
||||
return target.ArchVariation()
|
||||
}
|
||||
|
||||
func (target Target) ArchVariation() string {
|
||||
var variation string
|
||||
if target.NativeBridge {
|
||||
variant = "native_bridge_"
|
||||
variation = "native_bridge_"
|
||||
}
|
||||
variation += target.Arch.String()
|
||||
|
||||
return target.Os.String() + "_" + variation
|
||||
}
|
||||
|
||||
func (target Target) Variations() []blueprint.Variation {
|
||||
return []blueprint.Variation{
|
||||
{Mutator: "arch", Variation: target.ArchVariation()},
|
||||
}
|
||||
return target.Os.String() + "_" + variant + target.Arch.String()
|
||||
}
|
||||
|
||||
// archMutator splits a module into a variant for each Target requested by the module. Target selection
|
||||
|
@@ -89,9 +89,10 @@ type config struct {
|
||||
ConfigFileName string
|
||||
ProductVariablesFileName string
|
||||
|
||||
Targets map[OsType][]Target
|
||||
BuildOsVariant string
|
||||
BuildOsCommonVariant string
|
||||
Targets map[OsType][]Target
|
||||
BuildOSTarget Target // the Target for tools run on the build machine
|
||||
BuildOSCommonTarget Target // the Target for common (java) tools run on the build machine
|
||||
AndroidCommonTarget Target // the Target for common modules for the Android device
|
||||
|
||||
// multilibConflicts for an ArchType is true if there is earlier configured device architecture with the same
|
||||
// multilib value.
|
||||
@@ -289,8 +290,9 @@ func TestArchConfig(buildDir string, env map[string]string) Config {
|
||||
config.Targets[BuildOs] = config.Targets[BuildOs][:1]
|
||||
}
|
||||
|
||||
config.BuildOsVariant = config.Targets[BuildOs][0].String()
|
||||
config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String()
|
||||
config.BuildOSTarget = config.Targets[BuildOs][0]
|
||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[BuildOs])[0]
|
||||
config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
|
||||
config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64")
|
||||
config.TestProductVariables.DeviceArchVariant = proptools.StringPtr("armv8-a")
|
||||
config.TestProductVariables.DeviceSecondaryArch = proptools.StringPtr("arm")
|
||||
@@ -374,8 +376,11 @@ func NewConfig(srcDir, buildDir string) (Config, error) {
|
||||
}
|
||||
|
||||
config.Targets = targets
|
||||
config.BuildOsVariant = targets[BuildOs][0].String()
|
||||
config.BuildOsCommonVariant = getCommonTargets(targets[BuildOs])[0].String()
|
||||
config.BuildOSTarget = config.Targets[BuildOs][0]
|
||||
config.BuildOSCommonTarget = getCommonTargets(config.Targets[BuildOs])[0]
|
||||
if len(config.Targets[Android]) > 0 {
|
||||
config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
|
||||
}
|
||||
|
||||
if err := config.fromEnv(); err != nil {
|
||||
return Config{}, err
|
||||
|
@@ -52,9 +52,8 @@ func ProtoDeps(ctx BottomUpMutatorContext, p *ProtoProperties) {
|
||||
}
|
||||
|
||||
if plugin := String(p.Proto.Plugin); plugin != "" {
|
||||
ctx.AddFarVariationDependencies([]blueprint.Variation{
|
||||
{Mutator: "arch", Variation: ctx.Config().BuildOsVariant},
|
||||
}, ProtoPluginDepTag, "protoc-gen-"+plugin)
|
||||
ctx.AddFarVariationDependencies(ctx.Config().BuildOSTarget.Variations(),
|
||||
ProtoPluginDepTag, "protoc-gen-"+plugin)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user