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
This commit is contained in:
Colin Cross
2016-06-01 17:09:44 -07:00
parent b9db480385
commit a1ad8d1889
19 changed files with 366 additions and 476 deletions

View File

@@ -52,7 +52,7 @@ func (stl *stl) begin(ctx BaseModuleContext) {
ctx.ModuleErrorf("stl: %q is not a supported STL with sdk_version set", stl.Properties.Stl)
return ""
}
} else if ctx.HostType() == android.Windows {
} else if ctx.Os() == android.Windows {
switch stl.Properties.Stl {
case "libc++", "libc++_static", "libstdc++", "":
// libc++ is not supported on mingw
@@ -60,7 +60,7 @@ func (stl *stl) begin(ctx BaseModuleContext) {
case "none":
return ""
default:
ctx.ModuleErrorf("stl: %q is not a supported STL", stl.Properties.Stl)
ctx.ModuleErrorf("stl: %q is not a supported STL for windows", stl.Properties.Stl)
return ""
}
} else {
@@ -133,9 +133,9 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
flags.LdFlags = append(flags.LdFlags, "-lpthread", "-lm")
if ctx.staticBinary() {
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.HostType()]...)
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.Os()]...)
} else {
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.HostType()]...)
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.Os()]...)
}
} else {
if ctx.Arch().ArchType == android.Arm {
@@ -167,9 +167,9 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
flags.CppFlags = append(flags.CppFlags, "-nostdinc++")
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
if ctx.staticBinary() {
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.HostType()]...)
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.Os()]...)
} else {
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.HostType()]...)
flags.LdFlags = append(flags.LdFlags, hostDynamicGccLibs[ctx.Os()]...)
}
}
default:
@@ -179,10 +179,10 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
return flags
}
var hostDynamicGccLibs, hostStaticGccLibs map[android.HostType][]string
var hostDynamicGccLibs, hostStaticGccLibs map[android.OsType][]string
func init() {
hostDynamicGccLibs = map[android.HostType][]string{
hostDynamicGccLibs = map[android.OsType][]string{
android.Linux: []string{"-lgcc_s", "-lgcc", "-lc", "-lgcc_s", "-lgcc"},
android.Darwin: []string{"-lc", "-lSystem"},
android.Windows: []string{"-lmsvcr110", "-lmingw32", "-lgcc", "-lmoldname",
@@ -190,7 +190,7 @@ func init() {
"-lkernel32", "-lmingw32", "-lgcc", "-lmoldname", "-lmingwex",
"-lmsvcrt"},
}
hostStaticGccLibs = map[android.HostType][]string{
hostStaticGccLibs = map[android.OsType][]string{
android.Linux: []string{"-Wl,--start-group", "-lgcc", "-lgcc_eh", "-lc", "-Wl,--end-group"},
android.Darwin: []string{"NO_STATIC_HOST_BINARIES_ON_DARWIN"},
android.Windows: []string{"NO_STATIC_HOST_BINARIES_ON_WINDOWS"},