Don't assume host arch is always x86
This change fixes some places where host arch is assumed to be x86 to
form a path element like linux-x86. In preparation for non-x86 host
targets, the host arch part is derived from the context.
In addition, InstallForceOS() is refactored so that it can override not
only OsType, but also ArchType. Without this, the paths for the
robolectic modules will be changed from linux-x86 to linux-common, which
breaks several other places where the old paths are expected.
Bug: 134795810
Test: m
Change-Id: Ib38c715948ae546e55021ece82bac1d82e9e5da0
diff --git a/android/paths_test.go b/android/paths_test.go
index a9cd22b..d099f65 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -207,6 +207,7 @@
inRecovery bool
inRoot bool
forceOS *OsType
+ forceArch *ArchType
}
func (m moduleInstallPathContextImpl) Config() Config {
@@ -243,8 +244,8 @@
return false
}
-func (m moduleInstallPathContextImpl) InstallForceOS() *OsType {
- return m.forceOS
+func (m moduleInstallPathContextImpl) InstallForceOS() (*OsType, *ArchType) {
+ return m.forceOS, m.forceArch
}
func pathTestConfig(buildDir string) Config {
@@ -254,8 +255,8 @@
func TestPathForModuleInstall(t *testing.T) {
testConfig := pathTestConfig("")
- hostTarget := Target{Os: Linux}
- deviceTarget := Target{Os: Android}
+ hostTarget := Target{Os: Linux, Arch: Arch{ArchType: X86}}
+ deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
testCases := []struct {
name string
@@ -635,6 +636,7 @@
},
inTestcases: true,
forceOS: &Linux,
+ forceArch: &X86,
},
in: []string{"my_test", "my_test_bin"},
out: "host/linux-x86/testcases/my_test/my_test_bin",