Merge "Finish cc.Customizer"
This commit is contained in:
commit
fb8f9a800e
2 changed files with 51 additions and 10 deletions
57
cc/cc.go
57
cc/cc.go
|
@ -494,8 +494,15 @@ type BaseModuleContext interface {
|
|||
ModuleContextIntf
|
||||
}
|
||||
|
||||
type CustomizerFlagsContext interface {
|
||||
BaseModuleContext
|
||||
AppendCflags(...string)
|
||||
AppendLdflags(...string)
|
||||
AppendAsflags(...string)
|
||||
}
|
||||
|
||||
type Customizer interface {
|
||||
CustomizeProperties(BaseModuleContext)
|
||||
Flags(CustomizerFlagsContext)
|
||||
Properties() []interface{}
|
||||
}
|
||||
|
||||
|
@ -508,12 +515,15 @@ type feature interface {
|
|||
|
||||
type compiler interface {
|
||||
feature
|
||||
appendCflags([]string)
|
||||
appendAsflags([]string)
|
||||
compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths
|
||||
}
|
||||
|
||||
type linker interface {
|
||||
feature
|
||||
link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles android.Paths) android.Path
|
||||
appendLdflags([]string)
|
||||
installable() bool
|
||||
}
|
||||
|
||||
|
@ -562,7 +572,7 @@ type Module struct {
|
|||
multilib android.Multilib
|
||||
|
||||
// delegates, initialize before calling Init
|
||||
customizer Customizer
|
||||
Customizer Customizer
|
||||
features []feature
|
||||
compiler compiler
|
||||
linker linker
|
||||
|
@ -579,8 +589,8 @@ type Module struct {
|
|||
|
||||
func (c *Module) Init() (blueprint.Module, []interface{}) {
|
||||
props := []interface{}{&c.Properties, &c.unused}
|
||||
if c.customizer != nil {
|
||||
props = append(props, c.customizer.Properties()...)
|
||||
if c.Customizer != nil {
|
||||
props = append(props, c.Customizer.Properties()...)
|
||||
}
|
||||
if c.compiler != nil {
|
||||
props = append(props, c.compiler.props()...)
|
||||
|
@ -621,6 +631,21 @@ type moduleContextImpl struct {
|
|||
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 {
|
||||
return ctx.mod.clang(ctx.ctx)
|
||||
}
|
||||
|
@ -699,6 +724,10 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||
}
|
||||
ctx.ctx = ctx
|
||||
|
||||
if c.Customizer != nil {
|
||||
c.Customizer.Flags(ctx)
|
||||
}
|
||||
|
||||
flags := Flags{
|
||||
Toolchain: c.toolchain(ctx),
|
||||
Clang: c.clang(ctx),
|
||||
|
@ -847,10 +876,6 @@ func (c *Module) depsMutator(actx android.BottomUpMutatorContext) {
|
|||
}
|
||||
ctx.ctx = ctx
|
||||
|
||||
if c.customizer != nil {
|
||||
c.customizer.CustomizeProperties(ctx)
|
||||
}
|
||||
|
||||
c.begin(ctx)
|
||||
|
||||
deps := c.deps(ctx)
|
||||
|
@ -1106,6 +1131,14 @@ type baseCompiler struct {
|
|||
|
||||
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{} {
|
||||
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) {
|
||||
if ctx.toolchain().Is64Bit() {
|
||||
linker.dynamicProperties.RunPaths = []string{"../lib64", "lib64"}
|
||||
|
@ -1866,6 +1903,10 @@ func objectFactory() (blueprint.Module, []interface{}) {
|
|||
return module.Init()
|
||||
}
|
||||
|
||||
func (object *objectLinker) appendLdflags(flags []string) {
|
||||
panic(fmt.Errorf("appendLdflags on object Linker not supported"))
|
||||
}
|
||||
|
||||
func (object *objectLinker) props() []interface{} {
|
||||
return []interface{}{&object.Properties}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
// 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.
|
||||
func CheckBadCompilerFlags(ctx ModuleContext, prop string, flags []string) {
|
||||
func CheckBadCompilerFlags(ctx BaseModuleContext, prop string, flags []string) {
|
||||
for _, flag := range flags {
|
||||
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
|
||||
// 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 {
|
||||
flag = strings.TrimSpace(flag)
|
||||
|
||||
|
|
Loading…
Reference in a new issue