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
diff --git a/cc/cc.go b/cc/cc.go
index 417dc0d..18dd09c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -528,6 +528,7 @@
compiler compiler
linker linker
installer installer
+ stl *stl
outputFile common.OptionalPath
@@ -548,6 +549,9 @@
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 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 @@
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 @@
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 @@
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 580570d..23989d3 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -28,17 +28,15 @@
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) 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 @@
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")