aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/androidmk.go53
-rw-r--r--android/arch.go446
-rw-r--r--android/config.go23
-rw-r--r--android/module.go105
-rw-r--r--android/paths.go2
5 files changed, 253 insertions, 376 deletions
diff --git a/android/androidmk.go b/android/androidmk.go
index 603b37de..8d2951db 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -149,27 +149,21 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
name += "_" + data.SubName
}
- hostCross := false
- if amod.Host() && amod.HostType() != CurrentHostType() {
- hostCross = true
- }
-
if data.Custom != nil {
prefix := ""
- if amod.Host() {
- if hostCross {
- prefix = "HOST_CROSS_"
- } else {
- prefix = "HOST_"
- }
- if amod.Arch().ArchType != ctx.Config().(Config).HostArches[amod.HostType()][0].ArchType {
- prefix = "2ND_" + prefix
- }
- } else {
+ switch amod.Os().Class {
+ case Host:
+ prefix = "HOST_"
+ case HostCross:
+ prefix = "HOST_CROSS_"
+ case Device:
prefix = "TARGET_"
- if amod.Arch().ArchType != ctx.Config().(Config).DeviceArches[0].ArchType {
- prefix = "2ND_" + prefix
- }
+
+ }
+
+ config := ctx.Config().(Config)
+ if amod.Arch().ArchType != config.Targets[amod.Os().Class][0].Arch.ArchType {
+ prefix = "2ND_" + prefix
}
return data.Custom(w, name, prefix)
@@ -191,15 +185,15 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", data.OutputFile.String())
archStr := amod.Arch().ArchType.String()
- if amod.Host() {
- if hostCross {
- fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
- } else {
- fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
- }
- fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", amod.HostType().String())
- fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
- } else {
+ host := false
+ switch amod.Os().Class {
+ case Host:
+ fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
+ host = true
+ case HostCross:
+ fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
+ host = true
+ case Device:
fmt.Fprintln(w, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
if len(amod.commonProperties.Logtags) > 0 {
@@ -207,6 +201,11 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
}
}
+ if host {
+ fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", amod.Os().String())
+ fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
+ }
+
for _, extra := range data.Extra {
err = extra(w, data.OutputFile.Path())
if err != nil {
diff --git a/android/arch.go b/android/arch.go
index 48cc0ab7..184b1629 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -28,8 +28,6 @@ func init() {
RegisterBottomUpMutator("defaults_deps", defaultsDepsMutator)
RegisterTopDownMutator("defaults", defaultsMutator)
- RegisterBottomUpMutator("host_or_device", HostOrDeviceMutator)
- RegisterBottomUpMutator("host_type", HostTypeMutator)
RegisterBottomUpMutator("arch", ArchMutator)
}
@@ -333,75 +331,7 @@ func (a ArchType) String() string {
return a.Name
}
-type HostOrDeviceSupported int
-
-const (
- _ HostOrDeviceSupported = iota
- HostSupported
- DeviceSupported
- HostAndDeviceSupported
- HostAndDeviceDefault
-)
-
-type HostOrDevice int
-
-const (
- _ HostOrDevice = iota
- Host
- Device
-)
-
-func (hod HostOrDevice) String() string {
- switch hod {
- case Device:
- return "device"
- case Host:
- return "host"
- default:
- panic(fmt.Sprintf("unexpected HostOrDevice value %d", hod))
- }
-}
-
-func (hod HostOrDevice) Property() string {
- switch hod {
- case Device:
- return "android"
- case Host:
- return "host"
- default:
- panic(fmt.Sprintf("unexpected HostOrDevice value %d", hod))
- }
-}
-
-func (hod HostOrDevice) Host() bool {
- if hod == 0 {
- panic("HostOrDevice unset")
- }
- return hod == Host
-}
-
-func (hod HostOrDevice) Device() bool {
- if hod == 0 {
- panic("HostOrDevice unset")
- }
- return hod == Device
-}
-
-var hostOrDeviceName = map[HostOrDevice]string{
- Device: "device",
- Host: "host",
-}
-
-type HostType int
-
-const (
- NoHostType HostType = iota
- Linux
- Darwin
- Windows
-)
-
-func CurrentHostType() HostType {
+var BuildOs = func() OsType {
switch runtime.GOOS {
case "linux":
return Linux
@@ -410,98 +340,71 @@ func CurrentHostType() HostType {
default:
panic(fmt.Sprintf("unsupported OS: %s", runtime.GOOS))
}
-}
-
-func (ht HostType) String() string {
- switch ht {
- case Linux:
- return "linux"
- case Darwin:
- return "darwin"
- case Windows:
- return "windows"
- default:
- panic(fmt.Sprintf("unexpected HostType value %d", ht))
- }
-}
-
-func (ht HostType) Field() string {
- switch ht {
- case Linux:
- return "Linux"
- case Darwin:
- return "Darwin"
- case Windows:
- return "Windows"
- default:
- panic(fmt.Sprintf("unexpected HostType value %d", ht))
- }
-}
+}()
var (
- commonArch = Arch{
- ArchType: Common,
- }
-)
-
-func HostOrDeviceMutator(mctx BottomUpMutatorContext) {
- var module Module
- var ok bool
- if module, ok = mctx.Module().(Module); !ok {
- return
- }
+ osTypeList []OsType
- hods := []HostOrDevice{}
+ NoOsType OsType
+ Linux = NewOsType("linux", Host)
+ Darwin = NewOsType("darwin", Host)
+ Windows = NewOsType("windows", HostCross)
+ Android = NewOsType("android", Device)
+)
- if module.base().HostSupported() {
- hods = append(hods, Host)
- }
+type OsType struct {
+ Name, Field string
+ Class OsClass
+}
- if module.base().DeviceSupported() {
- hods = append(hods, Device)
- }
+type OsClass int
- if len(hods) == 0 {
- return
- }
+const (
+ Device OsClass = iota
+ Host
+ HostCross
+)
- hodNames := []string{}
- for _, hod := range hods {
- hodNames = append(hodNames, hod.String())
- }
+func (os OsType) String() string {
+ return os.Name
+}
- modules := mctx.CreateVariations(hodNames...)
- for i, m := range modules {
- m.(Module).base().SetHostOrDevice(hods[i])
+func NewOsType(name string, class OsClass) OsType {
+ os := OsType{
+ Name: name,
+ Field: strings.Title(name),
+ Class: class,
}
+ osTypeList = append(osTypeList, os)
+ return os
}
-func HostTypeMutator(mctx BottomUpMutatorContext) {
- var module Module
- var ok bool
- if module, ok = mctx.Module().(Module); !ok {
- return
+func osByName(name string) OsType {
+ for _, os := range osTypeList {
+ if os.Name == name {
+ return os
+ }
}
- if !module.base().HostSupported() || !module.base().HostOrDevice().Host() {
- return
- }
+ return NoOsType
+}
- buildTypes, err := decodeHostTypesProductVariables(mctx.Config().(Config).ProductVariables)
- if err != nil {
- mctx.ModuleErrorf("%s", err.Error())
- return
+var (
+ commonTarget = Target{
+ Os: Android,
+ Arch: Arch{
+ ArchType: Common,
+ },
}
+)
- typeNames := []string{}
- for _, ht := range buildTypes {
- typeNames = append(typeNames, ht.String())
- }
+type Target struct {
+ Os OsType
+ Arch Arch
+}
- modules := mctx.CreateVariations(typeNames...)
- for i, m := range modules {
- m.(Module).base().SetHostType(buildTypes[i])
- }
+func (target Target) String() string {
+ return target.Os.String() + "_" + target.Arch.String()
}
func ArchMutator(mctx BottomUpMutatorContext) {
@@ -511,40 +414,32 @@ func ArchMutator(mctx BottomUpMutatorContext) {
return
}
- moduleArches := []Arch{}
- multilib := module.base().commonProperties.Compile_multilib
+ osClasses := module.base().OsClassSupported()
- if module.base().HostSupported() && module.base().HostOrDevice().Host() {
- hostModuleArches, err := decodeMultilib(multilib, mctx.Config().(Config).HostArches[module.base().HostType()])
- if err != nil {
- mctx.ModuleErrorf("%s", err.Error())
- }
-
- moduleArches = append(moduleArches, hostModuleArches...)
+ if len(osClasses) == 0 {
+ return
}
- if module.base().DeviceSupported() && module.base().HostOrDevice().Device() {
- deviceModuleArches, err := decodeMultilib(multilib, mctx.Config().(Config).DeviceArches)
+ var moduleTargets []Target
+
+ for _, class := range osClasses {
+ multilib := module.base().commonProperties.Compile_multilib
+ targets, err := decodeMultilib(multilib, mctx.AConfig().Targets[class])
if err != nil {
mctx.ModuleErrorf("%s", err.Error())
}
-
- moduleArches = append(moduleArches, deviceModuleArches...)
+ moduleTargets = append(moduleTargets, targets...)
}
- if len(moduleArches) == 0 {
- return
- }
+ targetNames := make([]string, len(moduleTargets))
- archNames := []string{}
- for _, arch := range moduleArches {
- archNames = append(archNames, arch.String())
+ for i, target := range moduleTargets {
+ targetNames[i] = target.String()
}
- modules := mctx.CreateVariations(archNames...)
-
+ modules := mctx.CreateVariations(targetNames...)
for i, m := range modules {
- m.(Module).base().SetArch(moduleArches[i])
+ m.(Module).base().SetTarget(moduleTargets[i])
m.(Module).base().setArchProperties(mctx)
}
}
@@ -648,9 +543,8 @@ func (a *ModuleBase) appendProperties(ctx BottomUpMutatorContext,
// Rewrite the module's properties structs to contain arch-specific values.
func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
- arch := a.commonProperties.CompileArch
- hod := a.commonProperties.CompileHostOrDevice
- ht := a.commonProperties.CompileHostType
+ arch := a.Arch()
+ os := a.Os()
if arch.ArchType == Common {
return
@@ -719,18 +613,19 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
prefix = "multilib." + t.Multilib
a.appendProperties(ctx, genProps, archProps.Multilib, field, prefix)
- // Handle host-or-device-specific properties in the form:
+ // Handle host-specific properties in the form:
// target: {
// host: {
// key: value,
// },
// },
- hodProperty := hod.Property()
- field = proptools.FieldNameForProperty(hodProperty)
- prefix = "target." + hodProperty
- a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
+ if os.Class == Host || os.Class == HostCross {
+ field = "Host"
+ prefix = "target.host"
+ a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
+ }
- // Handle host target properties in the form:
+ // Handle target OS properties in the form:
// target: {
// linux: {
// key: value,
@@ -744,22 +639,29 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
// linux_arm: {
// key: value,
// },
+ // android {
+ // key: value,
+ // },
+ // android_arm {
+ // key: value,
+ // },
+ // android_x86 {
+ // key: value,
+ // },
// },
- if hod.Host() {
- field := ht.Field()
- prefix := "target." + ht.String()
- a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
+ // },
+ field = os.Field
+ prefix = "target." + os.Name
+ a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
- t := arch.ArchType
- field = ht.Field() + "_" + t.Name
- prefix = "target." + ht.String() + "_" + t.Name
- a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
+ field = os.Field + "_" + t.Name
+ prefix = "target." + os.Name + "_" + t.Name
+ a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
- if ht != Windows {
- field := "Not_windows"
- prefix := "target.not_windows"
- a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
- }
+ if (os.Class == Host || os.Class == HostCross) && os != Windows {
+ field := "Not_windows"
+ prefix := "target.not_windows"
+ a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
}
// Handle 64-bit device properties in the form:
@@ -775,8 +677,8 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
// options for all targets on a device that supports 64-bit binaries, not just the targets
// that are being compiled for 64-bit. Its expected use case is binaries like linker and
// debuggerd that need to know when they are a 32-bit process running on a 64-bit device
- if hod.Device() {
- if true /* && target_is_64_bit */ {
+ if os.Class == Device {
+ if ctx.AConfig().Android64() {
field := "Android64"
prefix := "target.android64"
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
@@ -786,26 +688,6 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
}
}
-
- // Handle device architecture properties in the form:
- // target {
- // android_arm {
- // key: value,
- // },
- // android_x86 {
- // key: value,
- // },
- // },
- if hod.Device() {
- t := arch.ArchType
- field := "Android_" + t.Name
- prefix := "target.android_" + t.Name
- a.appendProperties(ctx, genProps, archProps.Target, field, prefix)
- }
-
- if ctx.Failed() {
- return
- }
}
}
@@ -824,104 +706,84 @@ func forEachInterface(v reflect.Value, f func(reflect.Value)) {
}
}
-// Get a list of HostTypes from the product variables
-func decodeHostTypesProductVariables(variables productVariables) ([]HostType, error) {
- ret := []HostType{CurrentHostType()}
+// Convert the arch product variables into a list of targets for each os class structs
+func decodeTargetProductVariables(config Config) (map[OsClass][]Target, error) {
+ variables := config.ProductVariables
- if variables.CrossHost != nil && *variables.CrossHost != "" {
- switch *variables.CrossHost {
- case "windows":
- ret = append(ret, Windows)
- default:
- return nil, fmt.Errorf("Unsupported secondary host: %s", *variables.CrossHost)
+ targets := make(map[OsClass][]Target)
+ var targetErr error
+
+ addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi *[]string) {
+ if targetErr != nil {
+ return
}
- }
- return ret, nil
-}
+ arch, err := decodeArch(archName, archVariant, cpuVariant, abi)
+ if err != nil {
+ targetErr = err
+ return
+ }
-// Convert the arch product variables into a list of host and device Arch structs
-func decodeArchProductVariables(variables productVariables) (map[HostType][]Arch, []Arch, error) {
- if variables.HostArch == nil {
- return nil, nil, fmt.Errorf("No host primary architecture set")
+ targets[os.Class] = append(targets[os.Class],
+ Target{
+ Os: os,
+ Arch: arch,
+ })
}
- hostArch, err := decodeArch(*variables.HostArch, nil, nil, nil)
- if err != nil {
- return nil, nil, err
+ if variables.HostArch == nil {
+ return nil, fmt.Errorf("No host primary architecture set")
}
- hostArches := []Arch{hostArch}
+ addTarget(BuildOs, *variables.HostArch, nil, nil, nil)
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
- hostSecondaryArch, err := decodeArch(*variables.HostSecondaryArch, nil, nil, nil)
- if err != nil {
- return nil, nil, err
- }
- hostArches = append(hostArches, hostSecondaryArch)
- }
-
- hostTypeArches := map[HostType][]Arch{
- CurrentHostType(): hostArches,
+ addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
}
if variables.CrossHost != nil && *variables.CrossHost != "" {
- if variables.CrossHostArch == nil || *variables.CrossHostArch == "" {
- return nil, nil, fmt.Errorf("No cross-host primary architecture set")
+ crossHostOs := osByName(*variables.CrossHost)
+ if crossHostOs == NoOsType {
+ return nil, fmt.Errorf("Unknown cross host OS %q", *variables.CrossHost)
}
- crossHostArch, err := decodeArch(*variables.CrossHostArch, nil, nil, nil)
- if err != nil {
- return nil, nil, err
+ if variables.CrossHostArch == nil || *variables.CrossHostArch == "" {
+ return nil, fmt.Errorf("No cross-host primary architecture set")
}
- crossHostArches := []Arch{crossHostArch}
+ addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil)
if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
- crossHostSecondaryArch, err := decodeArch(*variables.CrossHostSecondaryArch, nil, nil, nil)
- if err != nil {
- return nil, nil, err
- }
- crossHostArches = append(crossHostArches, crossHostSecondaryArch)
- }
-
- switch *variables.CrossHost {
- case "windows":
- hostTypeArches[Windows] = crossHostArches
- default:
- return nil, nil, fmt.Errorf("Unsupported cross-host: %s", *variables.CrossHost)
+ addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil)
}
}
if variables.DeviceArch == nil {
- return nil, nil, fmt.Errorf("No device primary architecture set")
+ return nil, fmt.Errorf("No device primary architecture set")
}
- deviceArch, err := decodeArch(*variables.DeviceArch, variables.DeviceArchVariant,
+ addTarget(Android, *variables.DeviceArch, variables.DeviceArchVariant,
variables.DeviceCpuVariant, variables.DeviceAbi)
- if err != nil {
- return nil, nil, err
- }
-
- deviceArches := []Arch{deviceArch}
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
- deviceSecondaryArch, err := decodeArch(*variables.DeviceSecondaryArch,
+ addTarget(Android, *variables.DeviceSecondaryArch,
variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
variables.DeviceSecondaryAbi)
- if err != nil {
- return nil, nil, err
- }
- if deviceArch.ArchType.Multilib == deviceSecondaryArch.ArchType.Multilib {
- deviceSecondaryArch.Native = false
+
+ deviceArches := targets[Device]
+ if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
+ deviceArches[1].Arch.Native = false
}
- deviceArches = append(deviceArches, deviceSecondaryArch)
}
- return hostTypeArches, deviceArches, nil
+ if targetErr != nil {
+ return nil, targetErr
+ }
+
+ return targets, nil
}
-func decodeMegaDevice() ([]Arch, error) {
+func decodeMegaDevice() ([]Target, error) {
archSettings := []struct {
arch string
archVariant string
@@ -969,7 +831,7 @@ func decodeMegaDevice() ([]Arch, error) {
{"x86_64", "silvermont", "", []string{"x86_64"}},
}
- var ret []Arch
+ var ret []Target
for _, config := range archSettings {
arch, err := decodeArch(config.arch, &config.archVariant,
@@ -978,7 +840,10 @@ func decodeMegaDevice() ([]Arch, error) {
return nil, err
}
arch.Native = false
- ret = append(ret, arch)
+ ret = append(ret, Target{
+ Os: Android,
+ Arch: arch,
+ })
}
return ret, nil
@@ -1035,33 +900,32 @@ func decodeArch(arch string, archVariant, cpuVariant *string, abi *[]string) (Ar
return a, nil
}
-// Use the module multilib setting to select one or more arches from an arch list
-func decodeMultilib(multilib string, arches []Arch) ([]Arch, error) {
- buildArches := []Arch{}
+// Use the module multilib setting to select one or more targets from a target list
+func decodeMultilib(multilib string, targets []Target) ([]Target, error) {
+ buildTargets := []Target{}
switch multilib {
case "common":
- buildArches = append(buildArches, commonArch)
+ buildTargets = append(buildTargets, commonTarget)
case "both":
- buildArches = append(buildArches, arches...)
+ buildTargets = append(buildTargets, targets...)
case "first":
- buildArches = append(buildArches, arches[0])
+ buildTargets = append(buildTargets, targets[0])
case "32":
- for _, a := range arches {
- if a.ArchType.Multilib == "lib32" {
- buildArches = append(buildArches, a)
+ for _, t := range targets {
+ if t.Arch.ArchType.Multilib == "lib32" {
+ buildTargets = append(buildTargets, t)
}
}
case "64":
- for _, a := range arches {
- if a.ArchType.Multilib == "lib64" {
- buildArches = append(buildArches, a)
+ for _, t := range targets {
+ if t.Arch.ArchType.Multilib == "lib64" {
+ buildTargets = append(buildTargets, t)
}
}
default:
return nil, fmt.Errorf(`compile_multilib must be "both", "first", "32", or "64", found %q`,
multilib)
- //buildArches = append(buildArches, arches[0])
}
- return buildArches, nil
+ return buildTargets, nil
}
diff --git a/android/config.go b/android/config.go
index ee95d2ef..5024bcee 100644
--- a/android/config.go
+++ b/android/config.go
@@ -54,8 +54,8 @@ type config struct {
ConfigFileName string
ProductVariablesFileName string
- DeviceArches []Arch
- HostArches map[HostType][]Arch
+ Targets map[OsClass][]Target
+ BuildOsVariant string
srcDir string // the path of the root source directory
buildDir string // the path of the build output directory
@@ -175,20 +175,21 @@ func NewConfig(srcDir, buildDir string) (Config, error) {
config.inMake = true
}
- hostArches, deviceArches, err := decodeArchProductVariables(config.ProductVariables)
+ targets, err := decodeTargetProductVariables(config)
if err != nil {
return Config{}, err
}
if Bool(config.Mega_device) {
- deviceArches, err = decodeMegaDevice()
+ deviceTargets, err := decodeMegaDevice()
if err != nil {
return Config{}, err
}
+ targets[Device] = deviceTargets
}
- config.HostArches = hostArches
- config.DeviceArches = deviceArches
+ config.Targets = targets
+ config.BuildOsVariant = targets[Host][0].String()
return config, nil
}
@@ -325,3 +326,13 @@ func (c *config) SanitizeDevice() []string {
}
return *c.ProductVariables.SanitizeDevice
}
+
+func (c *config) Android64() bool {
+ for _, t := range c.Targets[Device] {
+ if t.Arch.ArchType.Multilib == "lib64" {
+ return true
+ }
+ }
+
+ return false
+}
diff --git a/android/module.go b/android/module.go
index 18555234..0e608d77 100644
--- a/android/module.go
+++ b/android/module.go
@@ -48,9 +48,9 @@ type ModuleBuildParams struct {
}
type androidBaseContext interface {
+ Target() Target
Arch() Arch
- HostOrDevice() HostOrDevice
- HostType() HostType
+ Os() OsType
Host() bool
Device() bool
Darwin() bool
@@ -90,7 +90,7 @@ type Module interface {
base() *ModuleBase
Enabled() bool
- HostOrDevice() HostOrDevice
+ Target() Target
InstallInData() bool
}
@@ -115,14 +115,8 @@ type commonProperties struct {
// file
Logtags []string
- // Set by HostOrDeviceMutator
- CompileHostOrDevice HostOrDevice `blueprint:"mutated"`
-
- // Set by HostTypeMutator
- CompileHostType HostType `blueprint:"mutated"`
-
- // Set by ArchMutator
- CompileArch Arch `blueprint:"mutated"`
+ // Set by TargetMutator
+ CompileTarget Target `blueprint:"mutated"`
// Set by InitAndroidModule
HostOrDeviceSupported HostOrDeviceSupported `blueprint:"mutated"`
@@ -142,6 +136,16 @@ const (
MultilibDefault Multilib = ""
)
+type HostOrDeviceSupported int
+
+const (
+ _ HostOrDeviceSupported = iota
+ HostSupported
+ DeviceSupported
+ HostAndDeviceSupported
+ HostAndDeviceDefault
+)
+
func InitAndroidModule(m Module,
propertyStructs ...interface{}) (blueprint.Module, []interface{}) {
@@ -241,38 +245,45 @@ func (a *ModuleBase) base() *ModuleBase {
return a
}
-func (a *ModuleBase) SetHostOrDevice(hod HostOrDevice) {
- a.commonProperties.CompileHostOrDevice = hod
-}
-
-func (a *ModuleBase) SetHostType(ht HostType) {
- a.commonProperties.CompileHostType = ht
-}
-
-func (a *ModuleBase) SetArch(arch Arch) {
- a.commonProperties.CompileArch = arch
+func (a *ModuleBase) SetTarget(target Target) {
+ a.commonProperties.CompileTarget = target
}
-func (a *ModuleBase) HostOrDevice() HostOrDevice {
- return a.commonProperties.CompileHostOrDevice
+func (a *ModuleBase) Target() Target {
+ return a.commonProperties.CompileTarget
}
-func (a *ModuleBase) HostType() HostType {
- return a.commonProperties.CompileHostType
+func (a *ModuleBase) Os() OsType {
+ return a.Target().Os
}
func (a *ModuleBase) Host() bool {
- return a.HostOrDevice().Host()
+ return a.Os().Class == Host || a.Os().Class == HostCross
}
func (a *ModuleBase) Arch() Arch {
- return a.commonProperties.CompileArch
+ return a.Target().Arch
}
-func (a *ModuleBase) HostSupported() bool {
- return a.commonProperties.HostOrDeviceSupported == HostSupported ||
- a.commonProperties.HostOrDeviceSupported == HostAndDeviceSupported &&
- a.hostAndDeviceProperties.Host_supported
+func (a *ModuleBase) OsClassSupported() []OsClass {
+ switch a.commonProperties.HostOrDeviceSupported {
+ case HostSupported:
+ // TODO(ccross): explicitly mark host cross support
+ return []OsClass{Host, HostCross}
+ case DeviceSupported:
+ return []OsClass{Device}
+ case HostAndDeviceSupported:
+ var supported []OsClass
+ if a.hostAndDeviceProperties.Host_supported {
+ supported = append(supported, Host, HostCross)
+ }
+ if a.hostAndDeviceProperties.Device_supported {
+ supported = append(supported, Device)
+ }
+ return supported
+ default:
+ return nil
+ }
}
func (a *ModuleBase) DeviceSupported() bool {
@@ -283,11 +294,7 @@ func (a *ModuleBase) DeviceSupported() bool {
func (a *ModuleBase) Enabled() bool {
if a.commonProperties.Enabled == nil {
- if a.HostSupported() && a.HostOrDevice().Host() && a.HostType() == Windows {
- return false
- } else {
- return true
- }
+ return a.Os().Class != HostCross
}
return *a.commonProperties.Enabled
}
@@ -376,9 +383,7 @@ func (a *ModuleBase) generateModuleTarget(ctx blueprint.ModuleContext) {
func (a *ModuleBase) androidBaseContextFactory(ctx blueprint.BaseModuleContext) androidBaseContextImpl {
return androidBaseContextImpl{
- arch: a.commonProperties.CompileArch,
- hod: a.commonProperties.CompileHostOrDevice,
- ht: a.commonProperties.CompileHostType,
+ target: a.commonProperties.CompileTarget,
proprietary: a.commonProperties.Proprietary,
config: ctx.Config().(Config),
installInData: a.module.InstallInData(),
@@ -413,9 +418,7 @@ func (a *ModuleBase) GenerateBuildActions(ctx blueprint.ModuleContext) {
}
type androidBaseContextImpl struct {
- arch Arch
- hod HostOrDevice
- ht HostType
+ target Target
debug bool
config Config
proprietary bool
@@ -494,28 +497,28 @@ func (a *androidModuleContext) AddMissingDependencies(deps []string) {
}
}
-func (a *androidBaseContextImpl) Arch() Arch {
- return a.arch
+func (a *androidBaseContextImpl) Target() Target {
+ return a.target
}
-func (a *androidBaseContextImpl) HostOrDevice() HostOrDevice {
- return a.hod
+func (a *androidBaseContextImpl) Arch() Arch {
+ return a.target.Arch
}
-func (a *androidBaseContextImpl) HostType() HostType {
- return a.ht
+func (a *androidBaseContextImpl) Os() OsType {
+ return a.target.Os
}
func (a *androidBaseContextImpl) Host() bool {
- return a.hod.Host()
+ return a.target.Os.Class == Host || a.target.Os.Class == HostCross
}
func (a *androidBaseContextImpl) Device() bool {
- return a.hod.Device()
+ return a.target.Os.Class == Device
}
func (a *androidBaseContextImpl) Darwin() bool {
- return a.hod.Host() && a.ht == Darwin
+ return a.target.Os == Darwin
}
func (a *androidBaseContextImpl) Debug() bool {
diff --git a/android/paths.go b/android/paths.go
index 910ebd28..35ed1801 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -629,7 +629,7 @@ func PathForModuleInstall(ctx ModuleContext, paths ...string) OutputPath {
}
outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition}
} else {
- outPaths = []string{"host", ctx.HostType().String() + "-x86"}
+ outPaths = []string{"host", ctx.Os().String() + "-x86"}
}
if ctx.Debug() {
outPaths = append([]string{"debug"}, outPaths...)