Promote stl to a fixed feature am: a8e07cc am: be9d860

am: 0ba6f91

* commit '0ba6f91be9d4e9858ec919ceaaf1c02bfad4318d':
  Promote stl to a fixed feature

Change-Id: I99b5f2972e1389408946dec46d0e6c6001acc54c
This commit is contained in:
Colin Cross
2016-04-25 21:38:26 +00:00
committed by android-build-merger
2 changed files with 19 additions and 10 deletions

View File

@@ -528,6 +528,7 @@ type Module struct {
compiler compiler compiler compiler
linker linker linker linker
installer installer installer installer
stl *stl
outputFile common.OptionalPath outputFile common.OptionalPath
@@ -548,6 +549,9 @@ func (c *Module) Init() (blueprint.Module, []interface{}) {
if c.installer != nil { if c.installer != nil {
props = append(props, c.installer.props()...) props = append(props, c.installer.props()...)
} }
if c.stl != nil {
props = append(props, c.stl.props()...)
}
for _, feature := range c.features { for _, feature := range c.features {
props = append(props, feature.props()...) props = append(props, feature.props()...)
} }
@@ -627,9 +631,7 @@ func newBaseModule(hod common.HostOrDeviceSupported, multilib common.Multilib) *
func newModule(hod common.HostOrDeviceSupported, multilib common.Multilib) *Module { func newModule(hod common.HostOrDeviceSupported, multilib common.Multilib) *Module {
module := newBaseModule(hod, multilib) module := newBaseModule(hod, multilib)
module.features = []feature{ module.stl = &stl{}
&stlFeature{},
}
return module return module
} }
@@ -653,6 +655,9 @@ func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) {
if c.linker != nil { if c.linker != nil {
flags = c.linker.flags(ctx, flags) flags = c.linker.flags(ctx, flags)
} }
if c.stl != nil {
flags = c.stl.flags(ctx, flags)
}
for _, feature := range c.features { for _, feature := range c.features {
flags = feature.flags(ctx, flags) flags = feature.flags(ctx, flags)
} }
@@ -726,6 +731,9 @@ func (c *Module) begin(ctx BaseModuleContext) {
if c.linker != nil { if c.linker != nil {
c.linker.begin(ctx) c.linker.begin(ctx)
} }
if c.stl != nil {
c.stl.begin(ctx)
}
for _, feature := range c.features { for _, feature := range c.features {
feature.begin(ctx) feature.begin(ctx)
} }
@@ -740,6 +748,9 @@ func (c *Module) deps(ctx BaseModuleContext) Deps {
if c.linker != nil { if c.linker != nil {
deps = c.linker.deps(ctx, deps) deps = c.linker.deps(ctx, deps)
} }
if c.stl != nil {
deps = c.stl.deps(ctx, deps)
}
for _, feature := range c.features { for _, feature := range c.features {
deps = feature.deps(ctx, deps) deps = feature.deps(ctx, deps)
} }

View File

@@ -28,17 +28,15 @@ type StlProperties struct {
SelectedStl string `blueprint:"mutated"` SelectedStl string `blueprint:"mutated"`
} }
type stlFeature struct { type stl struct {
Properties StlProperties Properties StlProperties
} }
var _ feature = (*stlFeature)(nil) func (stl *stl) props() []interface{} {
func (stl *stlFeature) props() []interface{} {
return []interface{}{&stl.Properties} return []interface{}{&stl.Properties}
} }
func (stl *stlFeature) begin(ctx BaseModuleContext) { func (stl *stl) begin(ctx BaseModuleContext) {
stl.Properties.SelectedStl = func() string { stl.Properties.SelectedStl = func() string {
if ctx.sdk() && ctx.Device() { if ctx.sdk() && ctx.Device() {
switch stl.Properties.Stl { switch stl.Properties.Stl {
@@ -84,7 +82,7 @@ func (stl *stlFeature) begin(ctx BaseModuleContext) {
}() }()
} }
func (stl *stlFeature) deps(ctx BaseModuleContext, deps Deps) Deps { func (stl *stl) deps(ctx BaseModuleContext, deps Deps) Deps {
switch stl.Properties.SelectedStl { switch stl.Properties.SelectedStl {
case "libstdc++": case "libstdc++":
if ctx.Device() { if ctx.Device() {
@@ -124,7 +122,7 @@ func (stl *stlFeature) deps(ctx BaseModuleContext, deps Deps) Deps {
return deps return deps
} }
func (stl *stlFeature) flags(ctx ModuleContext, flags Flags) Flags { func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags {
switch stl.Properties.SelectedStl { switch stl.Properties.SelectedStl {
case "libc++", "libc++_static": case "libc++", "libc++_static":
flags.CFlags = append(flags.CFlags, "-D_USING_LIBCXX") flags.CFlags = append(flags.CFlags, "-D_USING_LIBCXX")