diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2016-07-28 05:50:34 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-07-28 05:50:34 +0000 |
commit | fb8f9a800ed42e548893b13ebc3840fc31aaae94 (patch) | |
tree | 7b3e157b4d1116752078d06b3c8101380d34f27f /cc/cc.go | |
parent | 85676d22342d8f95b99981bd415b7de804d0de21 (diff) | |
parent | 76fada06c638767b8cd9a3edf37b74a4aefd035b (diff) | |
download | build_soong-fb8f9a800ed42e548893b13ebc3840fc31aaae94.tar.gz build_soong-fb8f9a800ed42e548893b13ebc3840fc31aaae94.tar.bz2 build_soong-fb8f9a800ed42e548893b13ebc3840fc31aaae94.zip |
Merge "Finish cc.Customizer"
Diffstat (limited to 'cc/cc.go')
-rw-r--r-- | cc/cc.go | 57 |
1 files changed, 49 insertions, 8 deletions
@@ -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} } |