aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2016-07-27 10:31:13 -0700
committerColin Cross <ccross@android.com>2016-07-27 17:15:49 -0700
commit76fada06c638767b8cd9a3edf37b74a4aefd035b (patch)
tree4622cfa76c8c75d295bc759b47a38ef49d6d0aad
parent5dab840e24efc133a9ad3eca1d43414599734e60 (diff)
downloadbuild_soong-76fada06c638767b8cd9a3edf37b74a4aefd035b.tar.gz
build_soong-76fada06c638767b8cd9a3edf37b74a4aefd035b.tar.bz2
build_soong-76fada06c638767b8cd9a3edf37b74a4aefd035b.zip
Finish cc.Customizer
The Customizer interface now provides a Flags method that takes a CustomizerFlagsContext and can call AppendCflags to insert extra cflags on a module. Change-Id: I821242e7574e8ff653580325d1bef2998a50e29c
-rw-r--r--cc/cc.go57
-rw-r--r--cc/check.go4
2 files changed, 51 insertions, 10 deletions
diff --git a/cc/cc.go b/cc/cc.go
index 30228fb3..60bc4d47 100644
--- a/cc/cc.go
+++ b/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}
}
diff --git a/cc/check.go b/cc/check.go
index 38a64a07..f4b28348 100644
--- a/cc/check.go
+++ b/cc/check.go
@@ -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)