Merge "Don't assume host arch is always x86"
This commit is contained in:
@@ -551,6 +551,15 @@ var BuildOs = func() OsType {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var BuildArch = func() ArchType {
|
||||||
|
switch runtime.GOARCH {
|
||||||
|
case "amd64":
|
||||||
|
return X86_64
|
||||||
|
default:
|
||||||
|
panic(fmt.Sprintf("unsupported Arch: %s", runtime.GOARCH))
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
var (
|
var (
|
||||||
OsTypeList []OsType
|
OsTypeList []OsType
|
||||||
commonTargetMap = make(map[string]Target)
|
commonTargetMap = make(map[string]Target)
|
||||||
|
@@ -198,7 +198,7 @@ type ModuleContext interface {
|
|||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
InstallInRoot() bool
|
InstallInRoot() bool
|
||||||
InstallBypassMake() bool
|
InstallBypassMake() bool
|
||||||
InstallForceOS() *OsType
|
InstallForceOS() (*OsType, *ArchType)
|
||||||
|
|
||||||
RequiredModuleNames() []string
|
RequiredModuleNames() []string
|
||||||
HostRequiredModuleNames() []string
|
HostRequiredModuleNames() []string
|
||||||
@@ -254,7 +254,7 @@ type Module interface {
|
|||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
InstallInRoot() bool
|
InstallInRoot() bool
|
||||||
InstallBypassMake() bool
|
InstallBypassMake() bool
|
||||||
InstallForceOS() *OsType
|
InstallForceOS() (*OsType, *ArchType)
|
||||||
SkipInstall()
|
SkipInstall()
|
||||||
IsSkipInstall() bool
|
IsSkipInstall() bool
|
||||||
MakeUninstallable()
|
MakeUninstallable()
|
||||||
@@ -1120,8 +1120,8 @@ func (m *ModuleBase) InstallBypassMake() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) InstallForceOS() *OsType {
|
func (m *ModuleBase) InstallForceOS() (*OsType, *ArchType) {
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModuleBase) Owner() string {
|
func (m *ModuleBase) Owner() string {
|
||||||
@@ -2021,7 +2021,7 @@ func (m *moduleContext) InstallBypassMake() bool {
|
|||||||
return m.module.InstallBypassMake()
|
return m.module.InstallBypassMake()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) InstallForceOS() *OsType {
|
func (m *moduleContext) InstallForceOS() (*OsType, *ArchType) {
|
||||||
return m.module.InstallForceOS()
|
return m.module.InstallForceOS()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ type ModuleInstallPathContext interface {
|
|||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
InstallInRoot() bool
|
InstallInRoot() bool
|
||||||
InstallBypassMake() bool
|
InstallBypassMake() bool
|
||||||
InstallForceOS() *OsType
|
InstallForceOS() (*OsType, *ArchType)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ ModuleInstallPathContext = ModuleContext(nil)
|
var _ ModuleInstallPathContext = ModuleContext(nil)
|
||||||
@@ -1278,12 +1278,17 @@ func (p InstallPath) ToMakePath() InstallPath {
|
|||||||
// module appended with paths...
|
// module appended with paths...
|
||||||
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
|
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
|
||||||
os := ctx.Os()
|
os := ctx.Os()
|
||||||
if forceOS := ctx.InstallForceOS(); forceOS != nil {
|
arch := ctx.Arch().ArchType
|
||||||
|
forceOS, forceArch := ctx.InstallForceOS()
|
||||||
|
if forceOS != nil {
|
||||||
os = *forceOS
|
os = *forceOS
|
||||||
}
|
}
|
||||||
|
if forceArch != nil {
|
||||||
|
arch = *forceArch
|
||||||
|
}
|
||||||
partition := modulePartition(ctx, os)
|
partition := modulePartition(ctx, os)
|
||||||
|
|
||||||
ret := pathForInstall(ctx, os, partition, ctx.Debug(), pathComponents...)
|
ret := pathForInstall(ctx, os, arch, partition, ctx.Debug(), pathComponents...)
|
||||||
|
|
||||||
if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() {
|
if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() {
|
||||||
ret = ret.ToMakePath()
|
ret = ret.ToMakePath()
|
||||||
@@ -1292,7 +1297,7 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func pathForInstall(ctx PathContext, os OsType, partition string, debug bool,
|
func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string, debug bool,
|
||||||
pathComponents ...string) InstallPath {
|
pathComponents ...string) InstallPath {
|
||||||
|
|
||||||
var outPaths []string
|
var outPaths []string
|
||||||
@@ -1300,15 +1305,21 @@ func pathForInstall(ctx PathContext, os OsType, partition string, debug bool,
|
|||||||
if os.Class == Device {
|
if os.Class == Device {
|
||||||
outPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
|
outPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
|
||||||
} else {
|
} else {
|
||||||
switch os {
|
osName := os.String()
|
||||||
case Linux:
|
if os == Linux {
|
||||||
outPaths = []string{"host", "linux-x86", partition}
|
// instead of linux_glibc
|
||||||
case LinuxBionic:
|
osName = "linux"
|
||||||
// TODO: should this be a separate top level, or shared with linux-x86?
|
|
||||||
outPaths = []string{"host", "linux_bionic-x86", partition}
|
|
||||||
default:
|
|
||||||
outPaths = []string{"host", os.String() + "-x86", partition}
|
|
||||||
}
|
}
|
||||||
|
// SOONG_HOST_OUT is set to out/host/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
|
||||||
|
// and HOST_PREBUILT_ARCH is forcibly set to x86 even on x86_64 hosts. We don't seem
|
||||||
|
// to have a plan to fix it (see the comment in build/make/core/envsetup.mk).
|
||||||
|
// Let's keep using x86 for the existing cases until we have a need to support
|
||||||
|
// other architectures.
|
||||||
|
archName := arch.String()
|
||||||
|
if os.Class == Host && (arch == X86_64 || arch == Common) {
|
||||||
|
archName = "x86"
|
||||||
|
}
|
||||||
|
outPaths = []string{"host", osName + "-" + archName, partition}
|
||||||
}
|
}
|
||||||
if debug {
|
if debug {
|
||||||
outPaths = append([]string{"debug"}, outPaths...)
|
outPaths = append([]string{"debug"}, outPaths...)
|
||||||
|
@@ -207,6 +207,7 @@ type moduleInstallPathContextImpl struct {
|
|||||||
inRecovery bool
|
inRecovery bool
|
||||||
inRoot bool
|
inRoot bool
|
||||||
forceOS *OsType
|
forceOS *OsType
|
||||||
|
forceArch *ArchType
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m moduleInstallPathContextImpl) Config() Config {
|
func (m moduleInstallPathContextImpl) Config() Config {
|
||||||
@@ -243,8 +244,8 @@ func (m moduleInstallPathContextImpl) InstallBypassMake() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m moduleInstallPathContextImpl) InstallForceOS() *OsType {
|
func (m moduleInstallPathContextImpl) InstallForceOS() (*OsType, *ArchType) {
|
||||||
return m.forceOS
|
return m.forceOS, m.forceArch
|
||||||
}
|
}
|
||||||
|
|
||||||
func pathTestConfig(buildDir string) Config {
|
func pathTestConfig(buildDir string) Config {
|
||||||
@@ -254,8 +255,8 @@ func pathTestConfig(buildDir string) Config {
|
|||||||
func TestPathForModuleInstall(t *testing.T) {
|
func TestPathForModuleInstall(t *testing.T) {
|
||||||
testConfig := pathTestConfig("")
|
testConfig := pathTestConfig("")
|
||||||
|
|
||||||
hostTarget := Target{Os: Linux}
|
hostTarget := Target{Os: Linux, Arch: Arch{ArchType: X86}}
|
||||||
deviceTarget := Target{Os: Android}
|
deviceTarget := Target{Os: Android, Arch: Arch{ArchType: Arm64}}
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -635,6 +636,7 @@ func TestPathForModuleInstall(t *testing.T) {
|
|||||||
},
|
},
|
||||||
inTestcases: true,
|
inTestcases: true,
|
||||||
forceOS: &Linux,
|
forceOS: &Linux,
|
||||||
|
forceArch: &X86,
|
||||||
},
|
},
|
||||||
in: []string{"my_test", "my_test_bin"},
|
in: []string{"my_test", "my_test_bin"},
|
||||||
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
out: "host/linux-x86/testcases/my_test/my_test_bin",
|
||||||
|
@@ -60,7 +60,7 @@ func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) W
|
|||||||
for _, module := range SortedStringKeys(files) {
|
for _, module := range SortedStringKeys(files) {
|
||||||
installedPaths = append(installedPaths, files[module]...)
|
installedPaths = append(installedPaths, files[module]...)
|
||||||
}
|
}
|
||||||
testCasesDir := pathForInstall(ctx, BuildOs, "testcases", false).ToMakePath()
|
testCasesDir := pathForInstall(ctx, BuildOs, X86, "testcases", false).ToMakePath()
|
||||||
|
|
||||||
outputFile := PathForOutput(ctx, "packaging", "robolectric-tests.zip")
|
outputFile := PathForOutput(ctx, "packaging", "robolectric-tests.zip")
|
||||||
rule := NewRuleBuilder()
|
rule := NewRuleBuilder()
|
||||||
|
@@ -328,7 +328,9 @@ func RobolectricTestFactory() android.Module {
|
|||||||
|
|
||||||
func (r *robolectricTest) InstallBypassMake() bool { return true }
|
func (r *robolectricTest) InstallBypassMake() bool { return true }
|
||||||
func (r *robolectricTest) InstallInTestcases() bool { return true }
|
func (r *robolectricTest) InstallInTestcases() bool { return true }
|
||||||
func (r *robolectricTest) InstallForceOS() *android.OsType { return &android.BuildOs }
|
func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) {
|
||||||
|
return &android.BuildOs, &android.BuildArch
|
||||||
|
}
|
||||||
|
|
||||||
func robolectricRuntimesFactory() android.Module {
|
func robolectricRuntimesFactory() android.Module {
|
||||||
module := &robolectricRuntimes{}
|
module := &robolectricRuntimes{}
|
||||||
@@ -392,4 +394,6 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont
|
|||||||
|
|
||||||
func (r *robolectricRuntimes) InstallBypassMake() bool { return true }
|
func (r *robolectricRuntimes) InstallBypassMake() bool { return true }
|
||||||
func (r *robolectricRuntimes) InstallInTestcases() bool { return true }
|
func (r *robolectricRuntimes) InstallInTestcases() bool { return true }
|
||||||
func (r *robolectricRuntimes) InstallForceOS() *android.OsType { return &android.BuildOs }
|
func (r *robolectricRuntimes) InstallForceOS() (*android.OsType, *android.ArchType) {
|
||||||
|
return &android.BuildOs, &android.BuildArch
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user