Separate HostOrDevice out of Arch

Take HostOrDevice out of Arch, and put it into AndroidModuleBase
instead.  Also separate out the host vs. device mutator from
ArchMutator.  This will make it possible for genrules to depend
on a host tool, regardless of which host arches it is compiled
for.

Change-Id: I22bbfd28b65c3eebdfa101a712f90dd615148dc8
diff --git a/common/module.go b/common/module.go
index d933788..ef7c63a 100644
--- a/common/module.go
+++ b/common/module.go
@@ -32,6 +32,7 @@
 
 type androidBaseContext interface {
 	Arch() Arch
+	HostOrDevice() HostOrDevice
 	Host() bool
 	Device() bool
 	Darwin() bool
@@ -86,6 +87,9 @@
 	// platform
 	Compile_multilib string
 
+	// Set by HostOrDeviceMutator
+	CompileHostOrDevice HostOrDevice `blueprint:"mutated"`
+
 	// Set by ArchMutator
 	CompileArch Arch `blueprint:"mutated"`
 
@@ -196,12 +200,16 @@
 	return a
 }
 
+func (a *AndroidModuleBase) SetHostOrDevice(hod HostOrDevice) {
+	a.commonProperties.CompileHostOrDevice = hod
+}
+
 func (a *AndroidModuleBase) SetArch(arch Arch) {
 	a.commonProperties.CompileArch = arch
 }
 
 func (a *AndroidModuleBase) HostOrDevice() HostOrDevice {
-	return a.commonProperties.CompileArch.HostOrDevice
+	return a.commonProperties.CompileHostOrDevice
 }
 
 func (a *AndroidModuleBase) HostSupported() bool {
@@ -293,6 +301,7 @@
 		DynamicDependerModuleContext: ctx,
 		androidBaseContextImpl: androidBaseContextImpl{
 			arch:   a.commonProperties.CompileArch,
+			hod:    a.commonProperties.CompileHostOrDevice,
 			config: ctx.Config().(Config),
 		},
 	}
@@ -309,6 +318,7 @@
 		ModuleContext: ctx,
 		androidBaseContextImpl: androidBaseContextImpl{
 			arch:   a.commonProperties.CompileArch,
+			hod:    a.commonProperties.CompileHostOrDevice,
 			config: ctx.Config().(Config),
 		},
 		installDeps:        a.computeInstallDeps(ctx),
@@ -336,6 +346,7 @@
 
 type androidBaseContextImpl struct {
 	arch   Arch
+	hod    HostOrDevice
 	debug  bool
 	config Config
 }
@@ -366,16 +377,20 @@
 	return a.arch
 }
 
+func (a *androidBaseContextImpl) HostOrDevice() HostOrDevice {
+	return a.hod
+}
+
 func (a *androidBaseContextImpl) Host() bool {
-	return a.arch.HostOrDevice.Host()
+	return a.hod.Host()
 }
 
 func (a *androidBaseContextImpl) Device() bool {
-	return a.arch.HostOrDevice.Device()
+	return a.hod.Device()
 }
 
 func (a *androidBaseContextImpl) Darwin() bool {
-	return a.arch.HostOrDevice.Host() && runtime.GOOS == "darwin"
+	return a.hod.Host() && runtime.GOOS == "darwin"
 }
 
 func (a *androidBaseContextImpl) Debug() bool {
@@ -391,7 +406,7 @@
 
 	config := a.AConfig()
 	var fullInstallPath string
-	if a.arch.HostOrDevice.Device() {
+	if a.hod.Device() {
 		// TODO: replace unset with a device name once we have device targeting
 		fullInstallPath = filepath.Join(config.DeviceOut(), "system",
 			installPath, name)