diff options
author | Colin Cross <ccross@android.com> | 2016-04-04 15:07:06 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2016-04-21 16:39:28 -0700 |
commit | a8e07cc6530b08e67aaf3bb6f64bedfc753d344f (patch) | |
tree | 2043f259b5a160b4c08041eb060e686dc69c18e6 /cc | |
parent | 919281aa918222fa2181c8dd19a2d2225f292180 (diff) | |
download | build_soong-a8e07cc6530b08e67aaf3bb6f64bedfc753d344f.tar.gz build_soong-a8e07cc6530b08e67aaf3bb6f64bedfc753d344f.tar.bz2 build_soong-a8e07cc6530b08e67aaf3bb6f64bedfc753d344f.zip |
Promote stl to a fixed feature
cc needs to know what stl was selected, promote stl from a generic
feature implementation to a fixed type pointer.
Change-Id: I950ef947f7cd254fe3074f4ff240bb2b90b9116c
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.go | 17 | ||||
-rw-r--r-- | cc/stl.go | 12 |
2 files changed, 19 insertions, 10 deletions
@@ -528,6 +528,7 @@ type Module struct { compiler compiler linker linker installer installer + stl *stl outputFile common.OptionalPath @@ -548,6 +549,9 @@ func (c *Module) Init() (blueprint.Module, []interface{}) { if c.installer != nil { props = append(props, c.installer.props()...) } + if c.stl != nil { + props = append(props, c.stl.props()...) + } for _, feature := range c.features { 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 { module := newBaseModule(hod, multilib) - module.features = []feature{ - &stlFeature{}, - } + module.stl = &stl{} return module } @@ -653,6 +655,9 @@ func (c *Module) GenerateAndroidBuildActions(actx common.AndroidModuleContext) { if c.linker != nil { flags = c.linker.flags(ctx, flags) } + if c.stl != nil { + flags = c.stl.flags(ctx, flags) + } for _, feature := range c.features { flags = feature.flags(ctx, flags) } @@ -726,6 +731,9 @@ func (c *Module) begin(ctx BaseModuleContext) { if c.linker != nil { c.linker.begin(ctx) } + if c.stl != nil { + c.stl.begin(ctx) + } for _, feature := range c.features { feature.begin(ctx) } @@ -740,6 +748,9 @@ func (c *Module) deps(ctx BaseModuleContext) Deps { if c.linker != nil { deps = c.linker.deps(ctx, deps) } + if c.stl != nil { + deps = c.stl.deps(ctx, deps) + } for _, feature := range c.features { deps = feature.deps(ctx, deps) } @@ -28,17 +28,15 @@ type StlProperties struct { SelectedStl string `blueprint:"mutated"` } -type stlFeature struct { +type stl struct { Properties StlProperties } -var _ feature = (*stlFeature)(nil) - -func (stl *stlFeature) props() []interface{} { +func (stl *stl) props() []interface{} { return []interface{}{&stl.Properties} } -func (stl *stlFeature) begin(ctx BaseModuleContext) { +func (stl *stl) begin(ctx BaseModuleContext) { stl.Properties.SelectedStl = func() string { if ctx.sdk() && ctx.Device() { 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 { case "libstdc++": if ctx.Device() { @@ -124,7 +122,7 @@ func (stl *stlFeature) deps(ctx BaseModuleContext, deps Deps) 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 { case "libc++", "libc++_static": flags.CFlags = append(flags.CFlags, "-D_USING_LIBCXX") |