HostCross is an attribute of a Target, not OsType
A host target is considered as being cross-compiled when the target can't run natively on the build machine. For example, linux_glibc/x86_64 is a non-cross target on a standard x86/Linux machine, but is a cross host on Mac. Previously, whether cross or not was a static attribute of an OsType. For example, Windows was always considered as cross host, while linux_bionic was not. This becomes a problem when we support more host targets like linux_bionic/arm64 which should be cross-host on standard x86/Linux machines. This change removes HostCross from the OsClass type and instead adds a property HostCross to the Target type. When a target is being added, it is initialized to true when the target can't run natively on the current build machine. Bug: 168086242 Test: m Change-Id: Ic37c8db918873ddf324c86b12b5412952b0f2be2
This commit is contained in:
parent
d55be35331
commit
1613e5541f
|
@ -304,15 +304,16 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
||||||
host := false
|
host := false
|
||||||
switch amod.Os().Class {
|
switch amod.Os().Class {
|
||||||
case Host:
|
case Host:
|
||||||
// Make cannot identify LOCAL_MODULE_HOST_ARCH:= common.
|
if amod.Target().HostCross {
|
||||||
if amod.Arch().ArchType != Common {
|
// Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
|
||||||
a.SetString("LOCAL_MODULE_HOST_ARCH", archStr)
|
if amod.Arch().ArchType != Common {
|
||||||
}
|
a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
|
||||||
host = true
|
}
|
||||||
case HostCross:
|
} else {
|
||||||
// Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
|
// Make cannot identify LOCAL_MODULE_HOST_ARCH:= common.
|
||||||
if amod.Arch().ArchType != Common {
|
if amod.Arch().ArchType != Common {
|
||||||
a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
|
a.SetString("LOCAL_MODULE_HOST_ARCH", archStr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
host = true
|
host = true
|
||||||
case Device:
|
case Device:
|
||||||
|
@ -359,9 +360,11 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
||||||
if amod.ArchSpecific() {
|
if amod.ArchSpecific() {
|
||||||
switch amod.Os().Class {
|
switch amod.Os().Class {
|
||||||
case Host:
|
case Host:
|
||||||
prefix = "HOST_"
|
if amod.Target().HostCross {
|
||||||
case HostCross:
|
prefix = "HOST_CROSS_"
|
||||||
prefix = "HOST_CROSS_"
|
} else {
|
||||||
|
prefix = "HOST_"
|
||||||
|
}
|
||||||
case Device:
|
case Device:
|
||||||
prefix = "TARGET_"
|
prefix = "TARGET_"
|
||||||
|
|
||||||
|
@ -563,9 +566,11 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod
|
||||||
if amod.ArchSpecific() {
|
if amod.ArchSpecific() {
|
||||||
switch amod.Os().Class {
|
switch amod.Os().Class {
|
||||||
case Host:
|
case Host:
|
||||||
prefix = "HOST_"
|
if amod.Target().HostCross {
|
||||||
case HostCross:
|
prefix = "HOST_CROSS_"
|
||||||
prefix = "HOST_CROSS_"
|
} else {
|
||||||
|
prefix = "HOST_"
|
||||||
|
}
|
||||||
case Device:
|
case Device:
|
||||||
prefix = "TARGET_"
|
prefix = "TARGET_"
|
||||||
|
|
||||||
|
|
|
@ -578,7 +578,7 @@ var (
|
||||||
Linux = NewOsType("linux_glibc", Host, false)
|
Linux = NewOsType("linux_glibc", Host, false)
|
||||||
Darwin = NewOsType("darwin", Host, false)
|
Darwin = NewOsType("darwin", Host, false)
|
||||||
LinuxBionic = NewOsType("linux_bionic", Host, false)
|
LinuxBionic = NewOsType("linux_bionic", Host, false)
|
||||||
Windows = NewOsType("windows", HostCross, true)
|
Windows = NewOsType("windows", Host, true)
|
||||||
Android = NewOsType("android", Device, false)
|
Android = NewOsType("android", Device, false)
|
||||||
Fuchsia = NewOsType("fuchsia", Device, false)
|
Fuchsia = NewOsType("fuchsia", Device, false)
|
||||||
|
|
||||||
|
@ -609,7 +609,6 @@ const (
|
||||||
Generic OsClass = iota
|
Generic OsClass = iota
|
||||||
Device
|
Device
|
||||||
Host
|
Host
|
||||||
HostCross
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (class OsClass) String() string {
|
func (class OsClass) String() string {
|
||||||
|
@ -620,8 +619,6 @@ func (class OsClass) String() string {
|
||||||
return "device"
|
return "device"
|
||||||
case Host:
|
case Host:
|
||||||
return "host"
|
return "host"
|
||||||
case HostCross:
|
|
||||||
return "host cross"
|
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unknown class %d", class))
|
panic(fmt.Errorf("unknown class %d", class))
|
||||||
}
|
}
|
||||||
|
@ -681,6 +678,11 @@ type Target struct {
|
||||||
NativeBridge NativeBridgeSupport
|
NativeBridge NativeBridgeSupport
|
||||||
NativeBridgeHostArchName string
|
NativeBridgeHostArchName string
|
||||||
NativeBridgeRelativePath string
|
NativeBridgeRelativePath string
|
||||||
|
|
||||||
|
// HostCross is true when the target cannot run natively on the current build host.
|
||||||
|
// For example, linux_glibc_x86 returns true on a regular x86/i686/Linux machines, but returns false
|
||||||
|
// on Mac (different OS), or on 64-bit only i686/Linux machines (unsupported arch).
|
||||||
|
HostCross bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (target Target) String() string {
|
func (target Target) String() string {
|
||||||
|
@ -739,26 +741,15 @@ func osMutator(bpctx blueprint.BottomUpMutatorContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
osClasses := base.OsClassSupported()
|
|
||||||
|
|
||||||
var moduleOSList []OsType
|
var moduleOSList []OsType
|
||||||
|
|
||||||
for _, os := range OsTypeList {
|
for _, os := range OsTypeList {
|
||||||
supportedClass := false
|
for _, t := range mctx.Config().Targets[os] {
|
||||||
for _, osClass := range osClasses {
|
if base.supportsTarget(t, mctx.Config()) {
|
||||||
if os.Class == osClass {
|
moduleOSList = append(moduleOSList, os)
|
||||||
supportedClass = true
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !supportedClass {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(mctx.Config().Targets[os]) == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleOSList = append(moduleOSList, os)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(moduleOSList) == 0 {
|
if len(moduleOSList) == 0 {
|
||||||
|
@ -913,7 +904,7 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
|
||||||
|
|
||||||
prefer32 := false
|
prefer32 := false
|
||||||
if base.prefer32 != nil {
|
if base.prefer32 != nil {
|
||||||
prefer32 = base.prefer32(mctx, base, os.Class)
|
prefer32 = base.prefer32(mctx, base, os)
|
||||||
}
|
}
|
||||||
|
|
||||||
multilib, extraMultilib := decodeMultilib(base, os.Class)
|
multilib, extraMultilib := decodeMultilib(base, os.Class)
|
||||||
|
@ -964,7 +955,7 @@ func decodeMultilib(base *ModuleBase, class OsClass) (multilib, extraMultilib st
|
||||||
switch class {
|
switch class {
|
||||||
case Device:
|
case Device:
|
||||||
multilib = String(base.commonProperties.Target.Android.Compile_multilib)
|
multilib = String(base.commonProperties.Target.Android.Compile_multilib)
|
||||||
case Host, HostCross:
|
case Host:
|
||||||
multilib = String(base.commonProperties.Target.Host.Compile_multilib)
|
multilib = String(base.commonProperties.Target.Host.Compile_multilib)
|
||||||
}
|
}
|
||||||
if multilib == "" {
|
if multilib == "" {
|
||||||
|
@ -1240,7 +1231,7 @@ func (m *ModuleBase) setOSProperties(ctx BottomUpMutatorContext) {
|
||||||
// key: value,
|
// key: value,
|
||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
if os.Class == Host || os.Class == HostCross {
|
if os.Class == Host {
|
||||||
field := "Host"
|
field := "Host"
|
||||||
prefix := "target.host"
|
prefix := "target.host"
|
||||||
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
@ -1280,7 +1271,7 @@ func (m *ModuleBase) setOSProperties(ctx BottomUpMutatorContext) {
|
||||||
prefix := "target." + os.Name
|
prefix := "target." + os.Name
|
||||||
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
|
||||||
if (os.Class == Host || os.Class == HostCross) && os != Windows {
|
if os.Class == Host && os != Windows {
|
||||||
field := "Not_windows"
|
field := "Not_windows"
|
||||||
prefix := "target.not_windows"
|
prefix := "target.not_windows"
|
||||||
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
m.appendProperties(ctx, genProps, targetProp, field, prefix)
|
||||||
|
@ -1508,6 +1499,36 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
||||||
nativeBridgeRelativePathStr = arch.ArchType.String()
|
nativeBridgeRelativePathStr = arch.ArchType.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A target is considered as HostCross if it's a host target which can't run natively on
|
||||||
|
// the currently configured build machine (either because the OS is different or because of
|
||||||
|
// the unsupported arch)
|
||||||
|
hostCross := false
|
||||||
|
if os.Class == Host {
|
||||||
|
var osSupported bool
|
||||||
|
if os == BuildOs {
|
||||||
|
osSupported = true
|
||||||
|
} else if BuildOs.Linux() && os.Linux() {
|
||||||
|
// LinuxBionic and Linux are compatible
|
||||||
|
osSupported = true
|
||||||
|
} else {
|
||||||
|
osSupported = false
|
||||||
|
}
|
||||||
|
|
||||||
|
var archSupported bool
|
||||||
|
if arch.ArchType == Common {
|
||||||
|
archSupported = true
|
||||||
|
} else if arch.ArchType.Name == *variables.HostArch {
|
||||||
|
archSupported = true
|
||||||
|
} else if variables.HostSecondaryArch != nil && arch.ArchType.Name == *variables.HostSecondaryArch {
|
||||||
|
archSupported = true
|
||||||
|
} else {
|
||||||
|
archSupported = false
|
||||||
|
}
|
||||||
|
if !osSupported || !archSupported {
|
||||||
|
hostCross = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
targets[os] = append(targets[os],
|
targets[os] = append(targets[os],
|
||||||
Target{
|
Target{
|
||||||
Os: os,
|
Os: os,
|
||||||
|
@ -1515,6 +1536,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
||||||
NativeBridge: nativeBridgeEnabled,
|
NativeBridge: nativeBridgeEnabled,
|
||||||
NativeBridgeHostArchName: nativeBridgeHostArchNameStr,
|
NativeBridgeHostArchName: nativeBridgeHostArchNameStr,
|
||||||
NativeBridgeRelativePath: nativeBridgeRelativePathStr,
|
NativeBridgeRelativePath: nativeBridgeRelativePathStr,
|
||||||
|
HostCross: hostCross,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,10 +260,10 @@ func TestArchConfigNativeBridge(buildDir string, env map[string]string, bp strin
|
||||||
config := testConfig.config
|
config := testConfig.config
|
||||||
|
|
||||||
config.Targets[Android] = []Target{
|
config.Targets[Android] = []Target{
|
||||||
{Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
|
{Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
{Android, Arch{ArchType: X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", ""},
|
{Android, Arch{ArchType: X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled, "x86_64", "arm64"},
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled, "x86_64", "arm64", false},
|
||||||
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled, "x86", "arm"},
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled, "x86", "arm", false},
|
||||||
}
|
}
|
||||||
|
|
||||||
return testConfig
|
return testConfig
|
||||||
|
@ -275,10 +275,10 @@ func TestArchConfigFuchsia(buildDir string, env map[string]string, bp string, fs
|
||||||
|
|
||||||
config.Targets = map[OsType][]Target{
|
config.Targets = map[OsType][]Target{
|
||||||
Fuchsia: []Target{
|
Fuchsia: []Target{
|
||||||
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
|
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
BuildOs: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,12 +292,12 @@ func TestArchConfig(buildDir string, env map[string]string, bp string, fs map[st
|
||||||
|
|
||||||
config.Targets = map[OsType][]Target{
|
config.Targets = map[OsType][]Target{
|
||||||
Android: []Target{
|
Android: []Target{
|
||||||
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", ""},
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
BuildOs: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
|
||||||
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", ""},
|
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", false},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -923,7 +923,7 @@ type ModuleBase struct {
|
||||||
initRcPaths Paths
|
initRcPaths Paths
|
||||||
vintfFragmentsPaths Paths
|
vintfFragmentsPaths Paths
|
||||||
|
|
||||||
prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
|
prefer32 func(ctx BaseModuleContext, base *ModuleBase, os OsType) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) ComponentDepsMutator(BottomUpMutatorContext) {}
|
func (m *ModuleBase) ComponentDepsMutator(BottomUpMutatorContext) {}
|
||||||
|
@ -950,7 +950,7 @@ func (m *ModuleBase) VariablesForTests() map[string]string {
|
||||||
return m.variables
|
return m.variables
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
|
func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, os OsType) bool) {
|
||||||
m.prefer32 = prefer32
|
m.prefer32 = prefer32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1046,7 +1046,7 @@ func (m *ModuleBase) Os() OsType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) Host() bool {
|
func (m *ModuleBase) Host() bool {
|
||||||
return m.Os().Class == Host || m.Os().Class == HostCross
|
return m.Os().Class == Host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) Device() bool {
|
func (m *ModuleBase) Device() bool {
|
||||||
|
@ -1066,28 +1066,28 @@ func (m *ModuleBase) IsCommonOSVariant() bool {
|
||||||
return m.commonProperties.CommonOSVariant
|
return m.commonProperties.CommonOSVariant
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) OsClassSupported() []OsClass {
|
func (m *ModuleBase) supportsTarget(target Target, config Config) bool {
|
||||||
switch m.commonProperties.HostOrDeviceSupported {
|
switch m.commonProperties.HostOrDeviceSupported {
|
||||||
case HostSupported:
|
case HostSupported:
|
||||||
return []OsClass{Host, HostCross}
|
return target.Os.Class == Host
|
||||||
case HostSupportedNoCross:
|
case HostSupportedNoCross:
|
||||||
return []OsClass{Host}
|
return target.Os.Class == Host && !target.HostCross
|
||||||
case DeviceSupported:
|
case DeviceSupported:
|
||||||
return []OsClass{Device}
|
return target.Os.Class == Device
|
||||||
case HostAndDeviceSupported, HostAndDeviceDefault:
|
case HostAndDeviceSupported, HostAndDeviceDefault:
|
||||||
var supported []OsClass
|
supported := false
|
||||||
if Bool(m.hostAndDeviceProperties.Host_supported) ||
|
if Bool(m.hostAndDeviceProperties.Host_supported) ||
|
||||||
(m.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
|
(m.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
|
||||||
m.hostAndDeviceProperties.Host_supported == nil) {
|
m.hostAndDeviceProperties.Host_supported == nil) {
|
||||||
supported = append(supported, Host, HostCross)
|
supported = supported || target.Os.Class == Host
|
||||||
}
|
}
|
||||||
if m.hostAndDeviceProperties.Device_supported == nil ||
|
if m.hostAndDeviceProperties.Device_supported == nil ||
|
||||||
*m.hostAndDeviceProperties.Device_supported {
|
*m.hostAndDeviceProperties.Device_supported {
|
||||||
supported = append(supported, Device)
|
supported = supported || target.Os.Class == Device
|
||||||
}
|
}
|
||||||
return supported
|
return supported
|
||||||
default:
|
default:
|
||||||
return nil
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2075,7 +2075,7 @@ func (b *baseModuleContext) Os() OsType {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) Host() bool {
|
func (b *baseModuleContext) Host() bool {
|
||||||
return b.os.Class == Host || b.os.Class == HostCross
|
return b.os.Class == Host
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *baseModuleContext) Device() bool {
|
func (b *baseModuleContext) Device() bool {
|
||||||
|
@ -2535,30 +2535,36 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
|
// Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
|
||||||
osDeps := map[OsType]Paths{}
|
type osAndCross struct {
|
||||||
|
os OsType
|
||||||
|
hostCross bool
|
||||||
|
}
|
||||||
|
osDeps := map[osAndCross]Paths{}
|
||||||
ctx.VisitAllModules(func(module Module) {
|
ctx.VisitAllModules(func(module Module) {
|
||||||
if module.Enabled() {
|
if module.Enabled() {
|
||||||
os := module.Target().Os
|
key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross}
|
||||||
osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
|
osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
osClass := make(map[string]Paths)
|
osClass := make(map[string]Paths)
|
||||||
for os, deps := range osDeps {
|
for key, deps := range osDeps {
|
||||||
var className string
|
var className string
|
||||||
|
|
||||||
switch os.Class {
|
switch key.os.Class {
|
||||||
case Host:
|
case Host:
|
||||||
className = "host"
|
if key.hostCross {
|
||||||
case HostCross:
|
className = "host-cross"
|
||||||
className = "host-cross"
|
} else {
|
||||||
|
className = "host"
|
||||||
|
}
|
||||||
case Device:
|
case Device:
|
||||||
className = "target"
|
className = "target"
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := className + "-" + os.Name
|
name := className + "-" + key.os.Name
|
||||||
osClass[className] = append(osClass[className], PathForPhony(ctx, name))
|
osClass[className] = append(osClass[className], PathForPhony(ctx, name))
|
||||||
|
|
||||||
ctx.Phony(name, deps...)
|
ctx.Phony(name, deps...)
|
||||||
|
|
|
@ -285,7 +285,7 @@ func TestPrebuilts(t *testing.T) {
|
||||||
t.Errorf("windows is assumed to be disabled by default")
|
t.Errorf("windows is assumed to be disabled by default")
|
||||||
}
|
}
|
||||||
config.config.Targets[Windows] = []Target{
|
config.config.Targets[Windows] = []Target{
|
||||||
{Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
|
{Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", true},
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := NewTestArchContext()
|
ctx := NewTestArchContext()
|
||||||
|
|
|
@ -157,13 +157,14 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
||||||
host := false
|
host := false
|
||||||
switch fi.module.Target().Os.Class {
|
switch fi.module.Target().Os.Class {
|
||||||
case android.Host:
|
case android.Host:
|
||||||
if fi.module.Target().Arch.ArchType != android.Common {
|
if fi.module.Target().HostCross {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
|
if fi.module.Target().Arch.ArchType != android.Common {
|
||||||
}
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
|
||||||
host = true
|
}
|
||||||
case android.HostCross:
|
} else {
|
||||||
if fi.module.Target().Arch.ArchType != android.Common {
|
if fi.module.Target().Arch.ArchType != android.Common {
|
||||||
fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
|
fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
host = true
|
host = true
|
||||||
case android.Device:
|
case android.Device:
|
||||||
|
|
4
cc/cc.go
4
cc/cc.go
|
@ -950,9 +950,9 @@ func (c *Module) Init() android.Module {
|
||||||
c.AddProperties(feature.props()...)
|
c.AddProperties(feature.props()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, class android.OsClass) bool {
|
c.Prefer32(func(ctx android.BaseModuleContext, base *android.ModuleBase, os android.OsType) bool {
|
||||||
// Windows builds always prefer 32-bit
|
// Windows builds always prefer 32-bit
|
||||||
return class == android.HostCross
|
return os == android.Windows
|
||||||
})
|
})
|
||||||
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
||||||
android.InitApexModule(c)
|
android.InitApexModule(c)
|
||||||
|
|
|
@ -678,7 +678,7 @@ func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext) {
|
||||||
seenModules[child] = true
|
seenModules[child] = true
|
||||||
|
|
||||||
// Skip host modules.
|
// Skip host modules.
|
||||||
if child.Target().Os.Class == android.Host || child.Target().Os.Class == android.HostCross {
|
if child.Target().Os.Class == android.Host {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PythonBinaryHostFactory() android.Module {
|
func PythonBinaryHostFactory() android.Module {
|
||||||
module, _ := NewBinary(android.HostSupportedNoCross)
|
module, _ := NewBinary(android.HostSupported)
|
||||||
|
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PythonLibraryHostFactory() android.Module {
|
func PythonLibraryHostFactory() android.Module {
|
||||||
module := newModule(android.HostSupportedNoCross, android.MultilibFirst)
|
module := newModule(android.HostSupported, android.MultilibFirst)
|
||||||
|
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,14 +68,14 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
|
||||||
// Add windows as a default disable OS to test behavior when some OS variants
|
// Add windows as a default disable OS to test behavior when some OS variants
|
||||||
// are disabled.
|
// are disabled.
|
||||||
config.Targets[android.Windows] = []android.Target{
|
config.Targets[android.Windows] = []android.Target{
|
||||||
{android.Windows, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", ""},
|
{android.Windows, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", true},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, extraOsType := range extraOsTypes {
|
for _, extraOsType := range extraOsTypes {
|
||||||
switch extraOsType {
|
switch extraOsType {
|
||||||
case android.LinuxBionic:
|
case android.LinuxBionic:
|
||||||
config.Targets[android.LinuxBionic] = []android.Target{
|
config.Targets[android.LinuxBionic] = []android.Target{
|
||||||
{android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", ""},
|
{android.LinuxBionic, android.Arch{ArchType: android.X86_64}, android.NativeBridgeDisabled, "", "", false},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
|
||||||
android.RegisterAndroidMkBuildComponents(ctx)
|
android.RegisterAndroidMkBuildComponents(ctx)
|
||||||
android.SetInMakeForTests(config)
|
android.SetInMakeForTests(config)
|
||||||
config.Targets[android.CommonOS] = []android.Target{
|
config.Targets[android.CommonOS] = []android.Target{
|
||||||
{android.CommonOS, android.Arch{ArchType: android.Common}, android.NativeBridgeDisabled, "", ""},
|
{android.CommonOS, android.Arch{ArchType: android.Common}, android.NativeBridgeDisabled, "", "", true},
|
||||||
}
|
}
|
||||||
|
|
||||||
// from android package
|
// from android package
|
||||||
|
|
|
@ -371,8 +371,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) andro
|
||||||
osPropertySet := targetPropertySet.AddPropertySet(sdkVariant.Target().Os.Name)
|
osPropertySet := targetPropertySet.AddPropertySet(sdkVariant.Target().Os.Name)
|
||||||
|
|
||||||
// Enable the variant explicitly when we've disabled it by default on host.
|
// Enable the variant explicitly when we've disabled it by default on host.
|
||||||
if hasHostOsDependentMember &&
|
if hasHostOsDependentMember && osType.Class == android.Host {
|
||||||
(osType.Class == android.Host || osType.Class == android.HostCross) {
|
|
||||||
osPropertySet.AddProperty("enabled", true)
|
osPropertySet.AddProperty("enabled", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,7 +730,7 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType
|
||||||
|
|
||||||
for _, variant := range member.Variants() {
|
for _, variant := range member.Variants() {
|
||||||
osClass := variant.Target().Os.Class
|
osClass := variant.Target().Os.Class
|
||||||
if osClass == android.Host || osClass == android.HostCross {
|
if osClass == android.Host {
|
||||||
hostSupported = true
|
hostSupported = true
|
||||||
} else if osClass == android.Device {
|
} else if osClass == android.Device {
|
||||||
deviceSupported = true
|
deviceSupported = true
|
||||||
|
@ -1061,8 +1060,7 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
|
||||||
archPropertySet = targetPropertySet
|
archPropertySet = targetPropertySet
|
||||||
|
|
||||||
// Enable the variant explicitly when we've disabled it by default on host.
|
// Enable the variant explicitly when we've disabled it by default on host.
|
||||||
if ctx.memberType.IsHostOsDependent() &&
|
if ctx.memberType.IsHostOsDependent() && osType.Class == android.Host {
|
||||||
(osType.Class == android.Host || osType.Class == android.HostCross) {
|
|
||||||
osPropertySet.AddProperty("enabled", true)
|
osPropertySet.AddProperty("enabled", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,7 +1084,7 @@ func (osInfo *osTypeSpecificInfo) addToPropertySet(ctx *memberContext, bpModule
|
||||||
|
|
||||||
func (osInfo *osTypeSpecificInfo) isHostVariant() bool {
|
func (osInfo *osTypeSpecificInfo) isHostVariant() bool {
|
||||||
osClass := osInfo.osType.Class
|
osClass := osInfo.osType.Class
|
||||||
return osClass == android.Host || osClass == android.HostCross
|
return osClass == android.Host
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ isHostVariant = (*osTypeSpecificInfo)(nil)
|
var _ isHostVariant = (*osTypeSpecificInfo)(nil)
|
||||||
|
@ -1323,7 +1321,7 @@ func (s *sdk) getPossibleOsTypes() []android.OsType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if s.HostSupported() {
|
if s.HostSupported() {
|
||||||
if osType.Class == android.Host || osType.Class == android.HostCross {
|
if osType.Class == android.Host {
|
||||||
osTypes = append(osTypes, osType)
|
osTypes = append(osTypes, osType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue