Merge "Finish cc.Customizer"
This commit is contained in:
commit
fb8f9a800e
57
cc/cc.go
57
cc/cc.go
|
@ -494,8 +494,15 @@ type BaseModuleContext interface {
|
||||||
ModuleContextIntf
|
ModuleContextIntf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CustomizerFlagsContext interface {
|
||||||
|
BaseModuleContext
|
||||||
|
AppendCflags(...string)
|
||||||
|
AppendLdflags(...string)
|
||||||
|
AppendAsflags(...string)
|
||||||
|
}
|
||||||
|
|
||||||
type Customizer interface {
|
type Customizer interface {
|
||||||
CustomizeProperties(BaseModuleContext)
|
Flags(CustomizerFlagsContext)
|
||||||
Properties() []interface{}
|
Properties() []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,12 +515,15 @@ type feature interface {
|
||||||
|
|
||||||
type compiler interface {
|
type compiler interface {
|
||||||
feature
|
feature
|
||||||
|
appendCflags([]string)
|
||||||
|
appendAsflags([]string)
|
||||||
compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths
|
compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
type linker interface {
|
type linker interface {
|
||||||
feature
|
feature
|
||||||
link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles android.Paths) android.Path
|
link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles android.Paths) android.Path
|
||||||
|
appendLdflags([]string)
|
||||||
installable() bool
|
installable() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +572,7 @@ type Module struct {
|
||||||
multilib android.Multilib
|
multilib android.Multilib
|
||||||
|
|
||||||
// delegates, initialize before calling Init
|
// delegates, initialize before calling Init
|
||||||
customizer Customizer
|
Customizer Customizer
|
||||||
features []feature
|
features []feature
|
||||||
compiler compiler
|
compiler compiler
|
||||||
linker linker
|
linker linker
|
||||||
|
@ -579,8 +589,8 @@ type Module struct {
|
||||||
|
|
||||||
func (c *Module) Init() (blueprint.Module, []interface{}) {
|
func (c *Module) Init() (blueprint.Module, []interface{}) {
|
||||||
props := []interface{}{&c.Properties, &c.unused}
|
props := []interface{}{&c.Properties, &c.unused}
|
||||||
if c.customizer != nil {
|
if c.Customizer != nil {
|
||||||
props = append(props, c.customizer.Properties()...)
|
props = append(props, c.Customizer.Properties()...)
|
||||||
}
|
}
|
||||||
if c.compiler != nil {
|
if c.compiler != nil {
|
||||||
props = append(props, c.compiler.props()...)
|
props = append(props, c.compiler.props()...)
|
||||||
|
@ -621,6 +631,21 @@ type moduleContextImpl struct {
|
||||||
ctx BaseModuleContext
|
ctx BaseModuleContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) AppendCflags(flags ...string) {
|
||||||
|
CheckBadCompilerFlags(ctx.ctx, "", flags)
|
||||||
|
ctx.mod.compiler.appendCflags(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) AppendAsflags(flags ...string) {
|
||||||
|
CheckBadCompilerFlags(ctx.ctx, "", flags)
|
||||||
|
ctx.mod.compiler.appendAsflags(flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *moduleContextImpl) AppendLdflags(flags ...string) {
|
||||||
|
CheckBadLinkerFlags(ctx.ctx, "", flags)
|
||||||
|
ctx.mod.linker.appendLdflags(flags)
|
||||||
|
}
|
||||||
|
|
||||||
func (ctx *moduleContextImpl) clang() bool {
|
func (ctx *moduleContextImpl) clang() bool {
|
||||||
return ctx.mod.clang(ctx.ctx)
|
return ctx.mod.clang(ctx.ctx)
|
||||||
}
|
}
|
||||||
|
@ -699,6 +724,10 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
||||||
}
|
}
|
||||||
ctx.ctx = ctx
|
ctx.ctx = ctx
|
||||||
|
|
||||||
|
if c.Customizer != nil {
|
||||||
|
c.Customizer.Flags(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
flags := Flags{
|
flags := Flags{
|
||||||
Toolchain: c.toolchain(ctx),
|
Toolchain: c.toolchain(ctx),
|
||||||
Clang: c.clang(ctx),
|
Clang: c.clang(ctx),
|
||||||
|
@ -847,10 +876,6 @@ func (c *Module) depsMutator(actx android.BottomUpMutatorContext) {
|
||||||
}
|
}
|
||||||
ctx.ctx = ctx
|
ctx.ctx = ctx
|
||||||
|
|
||||||
if c.customizer != nil {
|
|
||||||
c.customizer.CustomizeProperties(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
c.begin(ctx)
|
c.begin(ctx)
|
||||||
|
|
||||||
deps := c.deps(ctx)
|
deps := c.deps(ctx)
|
||||||
|
@ -1106,6 +1131,14 @@ type baseCompiler struct {
|
||||||
|
|
||||||
var _ compiler = (*baseCompiler)(nil)
|
var _ compiler = (*baseCompiler)(nil)
|
||||||
|
|
||||||
|
func (compiler *baseCompiler) appendCflags(flags []string) {
|
||||||
|
compiler.Properties.Cflags = append(compiler.Properties.Cflags, flags...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (compiler *baseCompiler) appendAsflags(flags []string) {
|
||||||
|
compiler.Properties.Asflags = append(compiler.Properties.Asflags, flags...)
|
||||||
|
}
|
||||||
|
|
||||||
func (compiler *baseCompiler) props() []interface{} {
|
func (compiler *baseCompiler) props() []interface{} {
|
||||||
return []interface{}{&compiler.Properties}
|
return []interface{}{&compiler.Properties}
|
||||||
}
|
}
|
||||||
|
@ -1317,6 +1350,10 @@ type baseLinker struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (linker *baseLinker) appendLdflags(flags []string) {
|
||||||
|
linker.Properties.Ldflags = append(linker.Properties.Ldflags, flags...)
|
||||||
|
}
|
||||||
|
|
||||||
func (linker *baseLinker) begin(ctx BaseModuleContext) {
|
func (linker *baseLinker) begin(ctx BaseModuleContext) {
|
||||||
if ctx.toolchain().Is64Bit() {
|
if ctx.toolchain().Is64Bit() {
|
||||||
linker.dynamicProperties.RunPaths = []string{"../lib64", "lib64"}
|
linker.dynamicProperties.RunPaths = []string{"../lib64", "lib64"}
|
||||||
|
@ -1866,6 +1903,10 @@ func objectFactory() (blueprint.Module, []interface{}) {
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (object *objectLinker) appendLdflags(flags []string) {
|
||||||
|
panic(fmt.Errorf("appendLdflags on object Linker not supported"))
|
||||||
|
}
|
||||||
|
|
||||||
func (object *objectLinker) props() []interface{} {
|
func (object *objectLinker) props() []interface{} {
|
||||||
return []interface{}{&object.Properties}
|
return []interface{}{&object.Properties}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
|
|
||||||
// Check for invalid c/conly/cpp/asflags and suggest alternatives. Only use this
|
// Check for invalid c/conly/cpp/asflags and suggest alternatives. Only use this
|
||||||
// for flags explicitly passed by the user, since these flags may be used internally.
|
// for flags explicitly passed by the user, since these flags may be used internally.
|
||||||
func CheckBadCompilerFlags(ctx ModuleContext, prop string, flags []string) {
|
func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {
|
||||||
for _, flag := range flags {
|
for _, flag := range flags {
|
||||||
flag = strings.TrimSpace(flag)
|
flag = strings.TrimSpace(flag)
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ func CheckBadCompilerFlags(ctx ModuleContext, prop string, flags []string) {
|
||||||
|
|
||||||
// Check for bad ldflags and suggest alternatives. Only use this for flags
|
// Check for bad ldflags and suggest alternatives. Only use this for flags
|
||||||
// explicitly passed by the user, since these flags may be used internally.
|
// explicitly passed by the user, since these flags may be used internally.
|
||||||
func CheckBadLinkerFlags(ctx ModuleContext, prop string, flags []string) {
|
func CheckBadLinkerFlags(ctx BaseModuleContext, prop string, flags []string) {
|
||||||
for _, flag := range flags {
|
for _, flag := range flags {
|
||||||
flag = strings.TrimSpace(flag)
|
flag = strings.TrimSpace(flag)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue