aboutsummaryrefslogtreecommitdiffstats
path: root/cc/makevars.go
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-06-01 17:09:44 -0700
committerColin Cross <ccross@android.com>2016-06-02 19:09:32 -0700
commita1ad8d1889e81be97b98f19969ed9147094f199c (patch)
treedada5b2274c750ccd8e7f5ad85b13e3922c2cc61 /cc/makevars.go
parentb9db480385745a9f42ea3f49a16877cb048960a9 (diff)
downloadbuild_soong-a1ad8d1889e81be97b98f19969ed9147094f199c.tar.gz
build_soong-a1ad8d1889e81be97b98f19969ed9147094f199c.tar.bz2
build_soong-a1ad8d1889e81be97b98f19969ed9147094f199c.zip
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
Diffstat (limited to 'cc/makevars.go')
-rw-r--r--cc/makevars.go81
1 files changed, 46 insertions, 35 deletions
diff --git a/cc/makevars.go b/cc/makevars.go
index 863e3dcc..f107eff8 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -41,49 +41,54 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("GLOBAL_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
- hostType := android.CurrentHostType()
- arches := ctx.Config().HostArches[hostType]
- makeVarsToolchain(ctx, "", android.Host, hostType, arches[0])
- if len(arches) > 1 {
- makeVarsToolchain(ctx, "2ND_", android.Host, hostType, arches[1])
+ hostTargets := ctx.Config().Targets[android.Host]
+ makeVarsToolchain(ctx, "", hostTargets[0])
+ if len(hostTargets) > 1 {
+ makeVarsToolchain(ctx, "2ND_", hostTargets[1])
}
- if winArches, ok := ctx.Config().HostArches[android.Windows]; ok {
- makeVarsToolchain(ctx, "", android.Host, android.Windows, winArches[0])
- if len(winArches) > 1 {
- makeVarsToolchain(ctx, "2ND_", android.Host, android.Windows, winArches[1])
+ crossTargets := ctx.Config().Targets[android.HostCross]
+ if len(crossTargets) > 0 {
+ makeVarsToolchain(ctx, "", crossTargets[0])
+ if len(crossTargets) > 1 {
+ makeVarsToolchain(ctx, "2ND_", crossTargets[1])
}
}
- arches = ctx.Config().DeviceArches
- makeVarsToolchain(ctx, "", android.Device, android.NoHostType, arches[0])
- if len(arches) > 1 {
- makeVarsToolchain(ctx, "2ND_", android.Device, android.NoHostType, arches[1])
+ deviceTargets := ctx.Config().Targets[android.Device]
+ makeVarsToolchain(ctx, "", deviceTargets[0])
+ if len(deviceTargets) > 1 {
+ makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
}
}
func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
- hod android.HostOrDevice, ht android.HostType, arch android.Arch) {
+ target android.Target) {
var typePrefix string
- if hod.Host() {
- if ht == android.Windows {
- typePrefix = "HOST_CROSS_"
- } else {
- typePrefix = "HOST_"
- }
- } else {
+ switch target.Os.Class {
+ case android.Host:
+ typePrefix = "HOST_"
+ case android.HostCross:
+ typePrefix = "HOST_CROSS_"
+ case android.Device:
typePrefix = "TARGET_"
}
makePrefix := secondPrefix + typePrefix
- toolchain := toolchainFactories[hod][ht][arch.ArchType](arch)
+ toolchain := toolchainFactories[target.Os][target.Arch.ArchType](target.Arch)
var productExtraCflags string
var productExtraLdflags string
- if hod.Device() && Bool(ctx.Config().ProductVariables.Brillo) {
+
+ hod := "host"
+ if target.Os.Class == android.Device {
+ hod = "device"
+ }
+
+ if target.Os.Class == android.Device && Bool(ctx.Config().ProductVariables.Brillo) {
productExtraCflags += "-D__BRILLO__"
}
- if hod.Host() && Bool(ctx.Config().ProductVariables.HostStaticBinaries) {
+ if target.Os.Class == android.Host && Bool(ctx.Config().ProductVariables.HostStaticBinaries) {
productExtraLdflags += "-static"
}
@@ -108,23 +113,29 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
ctx.Strict(makePrefix+"SYSTEMCPP_LDFLAGS", toolchain.SystemCppLdflags())
includeFlags, err := ctx.Eval(toolchain.IncludeFlags())
- if err != nil { panic(err) }
+ if err != nil {
+ panic(err)
+ }
ctx.StrictRaw(makePrefix+"C_INCLUDES", strings.Replace(includeFlags, "-isystem ", "", -1))
- if arch.ArchType == android.Arm {
+ if target.Arch.ArchType == android.Arm {
flags, err := toolchain.InstructionSetFlags("arm")
- if err != nil { panic(err) }
+ if err != nil {
+ panic(err)
+ }
ctx.Strict(makePrefix+"arm_CFLAGS", flags)
flags, err = toolchain.InstructionSetFlags("thumb")
- if err != nil { panic(err) }
+ if err != nil {
+ panic(err)
+ }
ctx.Strict(makePrefix+"thumb_CFLAGS", flags)
}
if toolchain.ClangSupported() {
clangPrefix := secondPrefix + "CLANG_" + typePrefix
clangExtras := "-target " + toolchain.ClangTriple()
- if ht != android.Darwin {
+ if target.Os != android.Darwin {
clangExtras += " -B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin")
}
@@ -148,19 +159,19 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
clangExtras,
}, " "))
- if hod.Device() {
- ctx.Strict(secondPrefix + "ADDRESS_SANITIZER_RUNTIME_LIBRARY", strings.TrimSuffix(toolchain.AddressSanitizerRuntimeLibrary(), ".so"))
+ if target.Os.Class == android.Device {
+ ctx.Strict(secondPrefix+"ADDRESS_SANITIZER_RUNTIME_LIBRARY", strings.TrimSuffix(toolchain.AddressSanitizerRuntimeLibrary(), ".so"))
}
// This is used by external/gentoo/...
- ctx.Strict("CLANG_CONFIG_" + arch.ArchType.Name + "_" + typePrefix + "TRIPLE",
+ ctx.Strict("CLANG_CONFIG_"+target.Arch.ArchType.Name+"_"+typePrefix+"TRIPLE",
toolchain.ClangTriple())
}
ctx.Strict(makePrefix+"CC", gccCmd(toolchain, "gcc"))
ctx.Strict(makePrefix+"CXX", gccCmd(toolchain, "g++"))
- if ht == android.Darwin {
+ if target.Os == android.Darwin {
ctx.Strict(makePrefix+"AR", "${macArPath}")
} else {
ctx.Strict(makePrefix+"AR", gccCmd(toolchain, "ar"))
@@ -168,11 +179,11 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
ctx.Strict(makePrefix+"NM", gccCmd(toolchain, "nm"))
}
- if ht == android.Windows {
+ if target.Os == android.Windows {
ctx.Strict(makePrefix+"OBJDUMP", gccCmd(toolchain, "objdump"))
}
- if hod.Device() {
+ if target.Os.Class == android.Device {
ctx.Strict(makePrefix+"OBJCOPY", gccCmd(toolchain, "objcopy"))
ctx.Strict(makePrefix+"LD", gccCmd(toolchain, "ld"))
ctx.Strict(makePrefix+"STRIP", gccCmd(toolchain, "strip"))