diff --git a/cc/cc.go b/cc/cc.go index 417dc0d0f..18dd09c74 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -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) } diff --git a/cc/stl.go b/cc/stl.go index 580570d76..23989d362 100644 --- a/cc/stl.go +++ b/cc/stl.go @@ -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")