Add per target archtecture properties

At least libcutils and boringssl need to set source files that
apply to x86 or x86_64, but only on the host or on the device.
Add new properties that can contain arch variant properties:
target.android_arm
target.android_arm64
target.android_mips
target.android_mips64
target.android_x86
target.android_x86_64
target.linux_x86
target.linux_x86_64
target.darwin_x86
target.darwin_x86_64

Change-Id: I5a7076653a7367a63daa7f7e34a6a28f5cbdfbe7
diff --git a/common/arch.go b/common/arch.go
index d4c17cf..38613a0 100644
--- a/common/arch.go
+++ b/common/arch.go
@@ -106,14 +106,24 @@
 		Lib64 interface{}
 	}
 	Target struct {
-		Host        interface{}
-		Android     interface{}
-		Android64   interface{}
-		Android32   interface{}
-		Linux       interface{}
-		Darwin      interface{}
-		Windows     interface{}
-		Not_windows interface{}
+		Host           interface{}
+		Android        interface{}
+		Android_arm    interface{}
+		Android_arm64  interface{}
+		Android_mips   interface{}
+		Android_mips64 interface{}
+		Android_x86    interface{}
+		Android_x86_64 interface{}
+		Android64      interface{}
+		Android32      interface{}
+		Linux          interface{}
+		Linux_x86      interface{}
+		Linux_x86_64   interface{}
+		Darwin         interface{}
+		Darwin_x86     interface{}
+		Darwin_x86_64  interface{}
+		Windows        interface{}
+		Not_windows    interface{}
 	}
 }
 
@@ -372,8 +382,8 @@
 		generalPropsValue := reflect.ValueOf(a.generalProperties[i]).Elem()
 
 		// Handle arch-specific properties in the form:
-		// arch {
-		//     arm64 {
+		// arch: {
+		//     arm64: {
 		//         key: value,
 		//     },
 		// },
@@ -382,8 +392,8 @@
 			reflect.ValueOf(a.archProperties[i].Arch).FieldByName(t.Field).Elem().Elem())
 
 		// Handle multilib-specific properties in the form:
-		// multilib {
-		//     lib32 {
+		// multilib: {
+		//     lib32: {
 		//         key: value,
 		//     },
 		// },
@@ -391,8 +401,8 @@
 			reflect.ValueOf(a.archProperties[i].Multilib).FieldByName(t.MultilibField).Elem().Elem())
 
 		// Handle host-or-device-specific properties in the form:
-		// target {
-		//     host {
+		// target: {
+		//     host: {
 		//         key: value,
 		//     },
 		// },
@@ -401,11 +411,17 @@
 			reflect.ValueOf(a.archProperties[i].Target).FieldByName(hod.Field()).Elem().Elem())
 
 		// Handle host target properties in the form:
-		// target {
-		//     linux {
+		// target: {
+		//     linux: {
 		//         key: value,
 		//     },
-		//     not_windows {
+		//     not_windows: {
+		//         key: value,
+		//     },
+		//     linux_x86: {
+		//         key: value,
+		//     },
+		//     linux_arm: {
 		//         key: value,
 		//     },
 		// },
@@ -423,6 +439,9 @@
 				if v.goos == runtime.GOOS {
 					a.extendProperties(ctx, "target", v.goos, generalPropsValue,
 						reflect.ValueOf(a.archProperties[i].Target).FieldByName(v.field).Elem().Elem())
+					t := arch.ArchType
+					a.extendProperties(ctx, "target", v.goos+"_"+t.Name, generalPropsValue,
+						reflect.ValueOf(a.archProperties[i].Target).FieldByName(v.field+"_"+t.Name).Elem().Elem())
 				}
 			}
 			a.extendProperties(ctx, "target", "not_windows", generalPropsValue,
@@ -451,6 +470,22 @@
 					reflect.ValueOf(a.archProperties[i].Target).FieldByName("Android32").Elem().Elem())
 			}
 		}
+
+		// Handle device architecture properties in the form:
+		// target {
+		//     android_arm {
+		//         key: value,
+		//     },
+		//     android_x86 {
+		//         key: value,
+		//     },
+		// },
+		if hod.Device() {
+			t := arch.ArchType
+			a.extendProperties(ctx, "target", "android_"+t.Name, generalPropsValue,
+				reflect.ValueOf(a.archProperties[i].Target).FieldByName("Android_"+t.Name).Elem().Elem())
+		}
+
 		if ctx.Failed() {
 			return
 		}