Encode default enabled state in OsType

Currently our only default-disabled Os is Windows since it's HostCross,
but we'll be adding non-default Host and Device types in the future.

Bug: 31559095
Test: out/soong/build.ninja is identical
Change-Id: I2bc3a3cc76f2c95ea040bc34ba6706fcc178c68d
This commit is contained in:
Dan Willemsen 2016-11-13 10:16:05 -08:00
parent ebedf678de
commit 0a37a2a2b8
2 changed files with 10 additions and 6 deletions

View File

@ -192,10 +192,10 @@ var (
osTypeList []OsType osTypeList []OsType
NoOsType OsType NoOsType OsType
Linux = NewOsType("linux", Host) Linux = NewOsType("linux", Host, false)
Darwin = NewOsType("darwin", Host) Darwin = NewOsType("darwin", Host, false)
Windows = NewOsType("windows", HostCross) Windows = NewOsType("windows", HostCross, true)
Android = NewOsType("android", Device) Android = NewOsType("android", Device, false)
osArchTypeMap = map[OsType][]ArchType{ osArchTypeMap = map[OsType][]ArchType{
Linux: []ArchType{X86, X86_64}, Linux: []ArchType{X86, X86_64},
@ -208,6 +208,8 @@ var (
type OsType struct { type OsType struct {
Name, Field string Name, Field string
Class OsClass Class OsClass
DefaultDisabled bool
} }
type OsClass int type OsClass int
@ -222,11 +224,13 @@ func (os OsType) String() string {
return os.Name return os.Name
} }
func NewOsType(name string, class OsClass) OsType { func NewOsType(name string, class OsClass, defDisabled bool) OsType {
os := OsType{ os := OsType{
Name: name, Name: name,
Field: strings.Title(name), Field: strings.Title(name),
Class: class, Class: class,
DefaultDisabled: defDisabled,
} }
osTypeList = append(osTypeList, os) osTypeList = append(osTypeList, os)
return os return os

View File

@ -355,7 +355,7 @@ func (a *ModuleBase) DeviceSupported() bool {
func (a *ModuleBase) Enabled() bool { func (a *ModuleBase) Enabled() bool {
if a.commonProperties.Enabled == nil { if a.commonProperties.Enabled == nil {
return a.Os().Class != HostCross return !a.Os().DefaultDisabled
} }
return *a.commonProperties.Enabled return *a.commonProperties.Enabled
} }