Export cc types for art to inherit from

Art needs a custom module type in order to perform complicated
build logic like depending on environment variables and varying
cflags based on cpu variant.  Export enough of the types and
functions from cc for art_cc_library to inherit from cc_library.

While I'm touching every line, also rename the New* methods
to *Factory.

Change-Id: I7123aa47019c4ced7a1ab57c394225bc7844b5ea
This commit is contained in:
Colin Cross 2015-03-23 17:50:24 -07:00
parent 70b4059e3f
commit 97ba073833
9 changed files with 337 additions and 328 deletions

View File

@ -128,7 +128,7 @@ func (t *toolchainArm64) ClangLdflags() string {
return "${arm64Ldflags}"
}
func arm64ToolchainFactory(archVariant string, cpuVariant string) toolchain {
func arm64ToolchainFactory(archVariant string, cpuVariant string) Toolchain {
return toolchainArm64Singleton
}

View File

@ -283,7 +283,7 @@ func (t *toolchainArm) ClangLdflags() string {
return t.ldflags
}
func armToolchainFactory(archVariant string, cpuVariant string) toolchain {
func armToolchainFactory(archVariant string, cpuVariant string) Toolchain {
return &toolchainArm{
cflags: strings.Join([]string{
"${armCflags}",

View File

@ -88,7 +88,7 @@ type builderFlags struct {
ldLibs string
incFlags string
nocrt bool
toolchain toolchain
toolchain Toolchain
clang bool
}
@ -283,6 +283,6 @@ func CopyGccLib(ctx common.AndroidModuleContext, libName string,
})
}
func gccCmd(toolchain toolchain, cmd string) string {
func gccCmd(toolchain Toolchain, cmd string) string {
return filepath.Join(toolchain.GccRoot(), "bin", toolchain.GccTriple()+"-"+cmd)
}

585
cc/cc.go

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ import (
"android/soong/common"
)
type toolchainFactory func(archVariant string, cpuVariant string) toolchain
type toolchainFactory func(archVariant string, cpuVariant string) Toolchain
var toolchainFactories = map[common.HostOrDevice]map[common.ArchType]toolchainFactory{
common.Host: make(map[common.ArchType]toolchainFactory),
@ -33,7 +33,7 @@ func registerToolchainFactory(hod common.HostOrDevice, arch common.ArchType,
toolchainFactories[hod][arch] = factory
}
type toolchain interface {
type Toolchain interface {
GccRoot() string
GccTriple() string
Cflags() string

View File

@ -79,18 +79,18 @@ func moduleToLibName(module string) (string, error) {
return matches[1], nil
}
func ccFlagsToBuilderFlags(in ccFlags) builderFlags {
func ccFlagsToBuilderFlags(in CCFlags) builderFlags {
return builderFlags{
globalFlags: strings.Join(in.globalFlags, " "),
asFlags: strings.Join(in.asFlags, " "),
cFlags: strings.Join(in.cFlags, " "),
conlyFlags: strings.Join(in.conlyFlags, " "),
cppFlags: strings.Join(in.cppFlags, " "),
ldFlags: strings.Join(in.ldFlags, " "),
ldLibs: strings.Join(in.ldLibs, " "),
incFlags: includeDirsToFlags(in.includeDirs),
nocrt: in.nocrt,
toolchain: in.toolchain,
clang: in.clang,
globalFlags: strings.Join(in.GlobalFlags, " "),
asFlags: strings.Join(in.AsFlags, " "),
cFlags: strings.Join(in.CFlags, " "),
conlyFlags: strings.Join(in.ConlyFlags, " "),
cppFlags: strings.Join(in.CppFlags, " "),
ldFlags: strings.Join(in.LdFlags, " "),
ldLibs: strings.Join(in.LdLibs, " "),
incFlags: includeDirsToFlags(in.IncludeDirs),
nocrt: in.Nocrt,
toolchain: in.Toolchain,
clang: in.Clang,
}
}

View File

@ -212,14 +212,14 @@ func (t *toolchainLinuxX8664) ClangLdflags() string {
return "${linuxClangLdflags} ${linuxX8664ClangLdflags}"
}
var toolchainLinuxX86Singleton toolchain = &toolchainLinuxX86{}
var toolchainLinuxX8664Singleton toolchain = &toolchainLinuxX8664{}
var toolchainLinuxX86Singleton Toolchain = &toolchainLinuxX86{}
var toolchainLinuxX8664Singleton Toolchain = &toolchainLinuxX8664{}
func linuxX86ToolchainFactory(archVariant string, cpuVariant string) toolchain {
func linuxX86ToolchainFactory(archVariant string, cpuVariant string) Toolchain {
return toolchainLinuxX86Singleton
}
func linuxX8664ToolchainFactory(archVariant string, cpuVariant string) toolchain {
func linuxX8664ToolchainFactory(archVariant string, cpuVariant string) Toolchain {
return toolchainLinuxX8664Singleton
}

View File

@ -38,20 +38,20 @@ func main() {
ctx := blueprint.NewContext()
// Module types
ctx.RegisterModuleType("cc_library_static", cc.NewCCLibraryStatic)
ctx.RegisterModuleType("cc_library_shared", cc.NewCCLibraryShared)
ctx.RegisterModuleType("cc_library", cc.NewCCLibrary)
ctx.RegisterModuleType("cc_object", cc.NewCCObject)
ctx.RegisterModuleType("cc_binary", cc.NewCCBinary)
ctx.RegisterModuleType("cc_test", cc.NewCCTest)
ctx.RegisterModuleType("cc_library_static", cc.CCLibraryStaticFactory)
ctx.RegisterModuleType("cc_library_shared", cc.CCLibrarySharedFactory)
ctx.RegisterModuleType("cc_library", cc.CCLibraryFactory)
ctx.RegisterModuleType("cc_object", cc.CCObjectFactory)
ctx.RegisterModuleType("cc_binary", cc.CCBinaryFactory)
ctx.RegisterModuleType("cc_test", cc.CCTestFactory)
ctx.RegisterModuleType("toolchain_library", cc.NewToolchainLibrary)
ctx.RegisterModuleType("toolchain_library", cc.ToolchainLibraryFactory)
ctx.RegisterModuleType("cc_library_host_static", cc.NewCCLibraryHostStatic)
ctx.RegisterModuleType("cc_library_host_shared", cc.NewCCLibraryHostShared)
ctx.RegisterModuleType("cc_binary_host", cc.NewCCBinaryHost)
ctx.RegisterModuleType("cc_library_host_static", cc.CCLibraryHostStaticFactory)
ctx.RegisterModuleType("cc_library_host_shared", cc.CCLibraryHostSharedFactory)
ctx.RegisterModuleType("cc_binary_host", cc.CCBinaryHostFactory)
ctx.RegisterModuleType("gensrcs", genrule.NewGenSrcs)
ctx.RegisterModuleType("gensrcs", genrule.GenSrcsFactory)
// Mutators
ctx.RegisterEarlyMutator("arch", common.ArchMutator)

View File

@ -53,7 +53,7 @@ type genSrcsProperties struct {
Output_extension string
}
func NewGenSrcs() (blueprint.Module, []interface{}) {
func GenSrcsFactory() (blueprint.Module, []interface{}) {
module := &genSrcs{}
return common.InitAndroidModule(module, &module.properties)