Revert "Simplify arch target handling"

This reverts commit 6713fb26cbcadf525cd75e47d7d0cbc23d282b3e.

Change-Id: Ic473cea2563b0b37dc08b0bc5d3a0ac8c4b6afe6
This commit is contained in:
Colin Cross
2016-06-03 01:50:47 +00:00
parent 54c7112c43
commit b9db480385
19 changed files with 474 additions and 360 deletions

View File

@@ -118,7 +118,7 @@ var (
)
func init() {
if android.BuildOs == android.Linux {
if android.CurrentHostType() == android.Linux {
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
}
@@ -729,10 +729,11 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
func (c *Module) toolchain(ctx BaseModuleContext) Toolchain {
if c.cachedToolchain == nil {
arch := ctx.Arch()
os := ctx.Os()
factory := toolchainFactories[os][arch.ArchType]
hod := ctx.HostOrDevice()
ht := ctx.HostType()
factory := toolchainFactories[hod][ht][arch.ArchType]
if factory == nil {
ctx.ModuleErrorf("Toolchain not found for %s arch %q", os.String(), arch.String())
ctx.ModuleErrorf("Toolchain not found for %s %s arch %q", hod.String(), ht.String(), arch.String())
return nil
}
c.cachedToolchain = factory(arch)
@@ -904,13 +905,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
if a.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), name)
return
}
if a.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), name)
if a.HostOrDevice() != ctx.HostOrDevice() {
ctx.ModuleErrorf("host/device mismatch between %q and %q", ctx.ModuleName(), name)
return
}
@@ -1085,11 +1081,6 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, target, gccPrefix)
}
hod := "host"
if ctx.Os().Class == android.Device {
hod = "device"
}
if !ctx.noDefaultCompilerFlags() {
flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags)
@@ -1099,7 +1090,7 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
flags.GlobalFlags = append(flags.GlobalFlags,
toolchain.ClangCflags(),
"${commonClangGlobalCflags}",
fmt.Sprintf("${%sClangGlobalCflags}", hod))
fmt.Sprintf("${%sClangGlobalCflags}", ctx.HostOrDevice()))
flags.ConlyFlags = append(flags.ConlyFlags, "${clangExtraConlyflags}")
} else {
@@ -1107,7 +1098,7 @@ func (compiler *baseCompiler) flags(ctx ModuleContext, flags Flags) Flags {
flags.GlobalFlags = append(flags.GlobalFlags,
toolchain.Cflags(),
"${commonGlobalCflags}",
fmt.Sprintf("${%sGlobalCflags}", hod))
fmt.Sprintf("${%sGlobalCflags}", ctx.HostOrDevice()))
}
if Bool(ctx.AConfig().ProductVariables.Brillo) {
@@ -1419,7 +1410,7 @@ func (library *libraryCompiler) flags(ctx ModuleContext, flags Flags) Flags {
// MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
// all code is position independent, and then those warnings get promoted to
// errors.
if ctx.Os() != android.Windows {
if ctx.HostType() != android.Windows {
flags.CFlags = append(flags.CFlags, "-fPIC")
}
@@ -1872,7 +1863,7 @@ func (binary *binaryLinker) begin(ctx BaseModuleContext) {
static := Bool(binary.Properties.Static_executable)
if ctx.Host() {
if ctx.Os() == android.Linux {
if ctx.HostType() == android.Linux {
if binary.Properties.Static_executable == nil && Bool(ctx.AConfig().ProductVariables.HostStaticBinaries) {
static = true
}
@@ -1892,7 +1883,7 @@ func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() && !binary.staticBinary() {
flags.LdFlags = append(flags.LdFlags, "-pie")
if ctx.Os() == android.Windows {
if ctx.HostType() == android.Windows {
flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup")
}
}
@@ -1900,7 +1891,7 @@ func (binary *binaryLinker) flags(ctx ModuleContext, flags Flags) Flags {
// MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
// all code is position independent, and then those warnings get promoted to
// errors.
if ctx.Os() != android.Windows {
if ctx.HostType() != android.Windows {
flags.CFlags = append(flags.CFlags, "-fpie")
}
@@ -1954,7 +1945,7 @@ func (binary *binaryLinker) link(ctx ModuleContext,
fileName := binary.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
outputFile := android.PathForModuleOut(ctx, fileName)
ret := outputFile
if ctx.Os().Class == android.Host {
if ctx.HostOrDevice().Host() {
binary.hostToolPath = android.OptionalPathForPath(outputFile)
}
@@ -2061,7 +2052,7 @@ func (test *testLinker) flags(ctx ModuleContext, flags Flags) Flags {
if ctx.Host() {
flags.CFlags = append(flags.CFlags, "-O0", "-g")
switch ctx.Os() {
switch ctx.HostType() {
case android.Windows:
flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS")
case android.Linux: