Skip to content

Commit

Permalink
spec: rename FeatureMap to OptionMap
Browse files Browse the repository at this point in the history
Intermediate step for renaming "features" to "options".

Signed-off-by: Enrico Weigelt, metux IT consult <[email protected]>
  • Loading branch information
metux committed Jan 15, 2024
1 parent af7ccb1 commit f1dbe78
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See [examples/pkg/zlib/metabuild.yaml](examples/pkg/zlib/metabuild.yaml)
or [examples/pkg/lincity/metabuild.yaml](examples/pkg/lincity/metabuild.yaml)
for an examples of the per package configuration.

Features
Options
--------

* purely declarative description of SW structure instead of rules for actual build process
Expand Down
2 changes: 1 addition & 1 deletion engine/autoconf/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func RunConfigure(cf global.Global) error {
return err
}
}
if err := RunConfigureFeatures(cf); err != nil {
if err := RunConfigureOptions(cf); err != nil {
return err
}

Expand Down
14 changes: 7 additions & 7 deletions engine/autoconf/features.go → engine/autoconf/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
type Key = spec.Key

// FIXME: move this out to frontend code
// FIXME: move env lookup into FeatureMap, but pass in env []
func featuresFromEnv(cf global.Global, fm features.FeatureMap) {
// FIXME: move env lookup into OptionMap, but pass in env []
func optionsFromEnv(cf global.Global, fm features.OptionMap) {
for _, f := range fm.All() {
fup := strings.ToUpper(string(f.Id))
if v := os.Getenv("ENABLE_" + fup); v != "" {
Expand All @@ -29,7 +29,7 @@ func featuresFromEnv(cf global.Global, fm features.FeatureMap) {
}
}

func featuresProcess(cf global.Global, fm features.FeatureMap) error {
func optionsProcess(cf global.Global, fm features.OptionMap) error {
bc := cf.BuildConf()

subBuild := bc.SubForBuild(true, "flags")
Expand Down Expand Up @@ -59,8 +59,8 @@ func featuresProcess(cf global.Global, fm features.FeatureMap) error {
return nil
}

func RunConfigureFeatures(cf global.Global) error {
fmap := cf.GetFeatureMap()
featuresFromEnv(cf, fmap)
return featuresProcess(cf, fmap)
func RunConfigureOptions(cf global.Global) error {
fmap := cf.GetOptionMap()
optionsFromEnv(cf, fmap)
return optionsProcess(cf, fmap)
}
2 changes: 1 addition & 1 deletion spec/buildconf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (

type BuildConf struct {
specobj.SpecObj
Features features.FeatureMap
Options features.OptionMap
}

// define a conditional/switch symbol
Expand Down
12 changes: 6 additions & 6 deletions spec/features/featuremap.go → spec/features/optionmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ import (
"github.com/metux/go-metabuild/util/specobj"
)

type FeatureMap struct {
type OptionMap struct {
specobj.SpecObj
}

func (fm FeatureMap) IDs() []Key {
func (fm OptionMap) IDs() []Key {
return fm.Keys()
}

func (fm FeatureMap) All() []Feature {
func (fm OptionMap) All() []Feature {
f := []Feature{}
for _, k := range fm.Keys() {
f = append(f, fm.Get(k))
}
return f
}

func (fm FeatureMap) Get(k Key) Feature {
func (fm OptionMap) Get(k Key) Feature {
return Feature{fm.EntrySpec(k), k}
}

func (fm FeatureMap) Map() map[Key]string {
func (fm OptionMap) Map() map[Key]string {
m := make(map[Key]string)
for _, k := range fm.Keys() {
m[k] = fm.EntryStr(k.Append(KeyEnabled))
}
return m
}

func (fm FeatureMap) Init() {
func (fm OptionMap) Init() {
for _, k := range fm.Keys() {
fm.DefaultPutStr(k.Append(KeyEnabled), "${@@PARENT::default}")
}
Expand Down
8 changes: 4 additions & 4 deletions spec/global/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ func (g Global) GetTargetObjects() map[string]target.TargetObject {
}

func (g Global) BuildConf() buildconf.BuildConf {
return buildconf.BuildConf{SpecObj: g.EntrySpec(KeyBuildConf), Features: g.GetFeatureMap()}
return buildconf.BuildConf{SpecObj: g.EntrySpec(KeyBuildConf), Options: g.GetOptionMap()}
}

func (g Global) GetCache() cache.Cache {
return cache.NewCache(g.EntrySpec(KeyCache))
}

func (g Global) GetFeatureMap() features.FeatureMap {
return features.FeatureMap{g.EntrySpec(KeyFeatures)}
func (g Global) GetOptionMap() features.OptionMap {
return features.OptionMap{g.EntrySpec(KeyFeatures)}
}

func (g Global) Init() {
Expand All @@ -88,7 +88,7 @@ func (g Global) Init() {
}

// init features
fm := g.GetFeatureMap()
fm := g.GetOptionMap()
fm.Init()

// init targets
Expand Down
4 changes: 2 additions & 2 deletions spec/target/targetobject.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type TargetObject struct {

func (o TargetObject) FeaturedStrList(k Key) []string {
ret := o.EntryStrList(k)
for _, f := range o.BuildConf.Features.All() {
for _, f := range o.BuildConf.Options.All() {
k2 := Key(string(k) + "@feature/" + string(f.Id) + "=" + f.ValueYN())
ret = append(ret, o.EntryStrList(k2)...)
}
Expand Down Expand Up @@ -181,7 +181,7 @@ func (o TargetObject) Skipped() bool {
}

for _, opt := range o.EntryStrList(KeyOptional) {
f := o.BuildConf.Features.Get(Key(opt))
f := o.BuildConf.Options.Get(Key(opt))
if !f.IsOn() {
return true
}
Expand Down

0 comments on commit f1dbe78

Please sign in to comment.