From f1dbe7838354bd8185b9763a8f1d5413be5c7ae7 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 15 Jan 2024 16:42:31 +0100 Subject: [PATCH] spec: rename FeatureMap to OptionMap Intermediate step for renaming "features" to "options". Signed-off-by: Enrico Weigelt, metux IT consult --- README.md | 2 +- engine/autoconf/configure.go | 2 +- engine/autoconf/{features.go => options.go} | 14 +++++++------- spec/buildconf/main.go | 2 +- spec/features/{featuremap.go => optionmap.go} | 12 ++++++------ spec/global/global.go | 8 ++++---- spec/target/targetobject.go | 4 ++-- 7 files changed, 22 insertions(+), 22 deletions(-) rename engine/autoconf/{features.go => options.go} (79%) rename spec/features/{featuremap.go => optionmap.go} (68%) diff --git a/README.md b/README.md index f7fad3de..51e43965 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/engine/autoconf/configure.go b/engine/autoconf/configure.go index 3e4b5873..36dc6803 100644 --- a/engine/autoconf/configure.go +++ b/engine/autoconf/configure.go @@ -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 } diff --git a/engine/autoconf/features.go b/engine/autoconf/options.go similarity index 79% rename from engine/autoconf/features.go rename to engine/autoconf/options.go index c0220e97..dc0c3e24 100644 --- a/engine/autoconf/features.go +++ b/engine/autoconf/options.go @@ -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 != "" { @@ -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") @@ -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) } diff --git a/spec/buildconf/main.go b/spec/buildconf/main.go index 5f16eea0..e07e3043 100644 --- a/spec/buildconf/main.go +++ b/spec/buildconf/main.go @@ -21,7 +21,7 @@ const ( type BuildConf struct { specobj.SpecObj - Features features.FeatureMap + Options features.OptionMap } // define a conditional/switch symbol diff --git a/spec/features/featuremap.go b/spec/features/optionmap.go similarity index 68% rename from spec/features/featuremap.go rename to spec/features/optionmap.go index e1d5c777..4808609d 100644 --- a/spec/features/featuremap.go +++ b/spec/features/optionmap.go @@ -4,15 +4,15 @@ 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)) @@ -20,11 +20,11 @@ func (fm FeatureMap) All() []Feature { 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)) @@ -32,7 +32,7 @@ func (fm FeatureMap) Map() map[Key]string { return m } -func (fm FeatureMap) Init() { +func (fm OptionMap) Init() { for _, k := range fm.Keys() { fm.DefaultPutStr(k.Append(KeyEnabled), "${@@PARENT::default}") } diff --git a/spec/global/global.go b/spec/global/global.go index 98e5f100..2b30ff25 100644 --- a/spec/global/global.go +++ b/spec/global/global.go @@ -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() { @@ -88,7 +88,7 @@ func (g Global) Init() { } // init features - fm := g.GetFeatureMap() + fm := g.GetOptionMap() fm.Init() // init targets diff --git a/spec/target/targetobject.go b/spec/target/targetobject.go index 187a8d96..90e10e4e 100644 --- a/spec/target/targetobject.go +++ b/spec/target/targetobject.go @@ -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)...) } @@ -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 }