Simplify arch target handling

Soong's multi-architecture building has grown complex, with the
combination of HostOrDevice+HostType+Arch necessary to determine how to
build a variant of a module, and three separate mutators to split each
into its variations.

Combine HostOrDevice+HostType into Os, which will be Linux, Darwin,
Windows, or Android.  Store Os+Arch as a single Target.

Change-Id: I92f2e2dac53617d595a35cc285d2bd348baa0fbd
diff --git a/android/androidmk.go b/android/androidmk.go
index 603b37d..8d2951d 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -149,27 +149,21 @@
 		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 @@
 	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 @@
 		}
 	}
 
+	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 {