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
diff --git a/android/androidmk.go b/android/androidmk.go
index fafbfd6..e90e5f0 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -304,15 +304,16 @@
host := false
switch amod.Os().Class {
case Host:
- // Make cannot identify LOCAL_MODULE_HOST_ARCH:= 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 amod.Arch().ArchType != Common {
- a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
+ if amod.Target().HostCross {
+ // Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
+ if amod.Arch().ArchType != Common {
+ a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
+ }
+ } else {
+ // Make cannot identify LOCAL_MODULE_HOST_ARCH:= common.
+ if amod.Arch().ArchType != Common {
+ a.SetString("LOCAL_MODULE_HOST_ARCH", archStr)
+ }
}
host = true
case Device:
@@ -359,9 +360,11 @@
if amod.ArchSpecific() {
switch amod.Os().Class {
case Host:
- prefix = "HOST_"
- case HostCross:
- prefix = "HOST_CROSS_"
+ if amod.Target().HostCross {
+ prefix = "HOST_CROSS_"
+ } else {
+ prefix = "HOST_"
+ }
case Device:
prefix = "TARGET_"
@@ -563,9 +566,11 @@
if amod.ArchSpecific() {
switch amod.Os().Class {
case Host:
- prefix = "HOST_"
- case HostCross:
- prefix = "HOST_CROSS_"
+ if amod.Target().HostCross {
+ prefix = "HOST_CROSS_"
+ } else {
+ prefix = "HOST_"
+ }
case Device:
prefix = "TARGET_"