You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/03/22 14:30:47 UTC
[mynewt-newt] branch master updated (4d5eccd -> 763d5c0)
This is an automated email from the ASF dual-hosted git repository.
andk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git.
from 4d5eccd cmake: Minor reformat
new 7a04837 Add experimental state for syscfg
new 763d5c0 Add single state config for syscfg
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
newt/builder/targetbuild.go | 4 ++++
newt/resolve/resolve.go | 4 ++++
newt/syscfg/marshal.go | 7 ++++---
newt/syscfg/syscfg.go | 46 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 58 insertions(+), 3 deletions(-)
[mynewt-newt] 01/02: Add experimental state for syscfg
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 7a04837f0663b74ee6fe547a1650b4869610e6ba
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Mar 22 11:04:41 2022 +0100
Add experimental state for syscfg
This will produce warning if used.
---
newt/builder/targetbuild.go | 4 ++++
newt/resolve/resolve.go | 4 ++++
newt/syscfg/marshal.go | 7 ++++---
newt/syscfg/syscfg.go | 28 ++++++++++++++++++++++++++++
4 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index 57e4952..532db09 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -275,6 +275,10 @@ func (t *TargetBuilder) validateAndWriteCfg() error {
log.Warn(line)
}
+ for _, line := range t.res.ExperimentalWarning() {
+ log.Warn(line)
+ }
+
incDir := GeneratedIncludeDir(t.target.FullName())
srcDir := GeneratedSrcDir(t.target.FullName())
diff --git a/newt/resolve/resolve.go b/newt/resolve/resolve.go
index 684b3c1..84e2aab 100644
--- a/newt/resolve/resolve.go
+++ b/newt/resolve/resolve.go
@@ -1357,6 +1357,10 @@ func (res *Resolution) DeprecatedWarning() []string {
return res.Cfg.DeprecatedWarning()
}
+func (res *Resolution) ExperimentalWarning() []string {
+ return res.Cfg.ExperimentalWarning()
+}
+
func LogTransientWarning(lpkg *pkg.LocalPackage) {
if lpkg.Type() == pkg.PACKAGE_TYPE_TRANSIENT {
log.Warnf("Transient package %s used, update configuration "+
diff --git a/newt/syscfg/marshal.go b/newt/syscfg/marshal.go
index 73c8428..5b3f2a0 100644
--- a/newt/syscfg/marshal.go
+++ b/newt/syscfg/marshal.go
@@ -32,9 +32,10 @@ var cfgSettingNameTypeMap = map[string]CfgSettingType{
}
var cfgSettingNameStateMap = map[string]CfgSettingState{
- "good": CFG_SETTING_STATE_GOOD,
- "deprecated": CFG_SETTING_STATE_DEPRECATED,
- "defunct": CFG_SETTING_STATE_DEFUNCT,
+ "good": CFG_SETTING_STATE_GOOD,
+ "deprecated": CFG_SETTING_STATE_DEPRECATED,
+ "defunct": CFG_SETTING_STATE_DEFUNCT,
+ "experimental": CFG_SETTING_STATE_EXPERIMENTAL,
}
var cfgFlashConflictNameCodeMap = map[string]CfgFlashConflictCode{
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 90645d3..ae30e9e 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -63,6 +63,7 @@ const (
CFG_SETTING_STATE_CONST
CFG_SETTING_STATE_DEPRECATED
CFG_SETTING_STATE_DEFUNCT
+ CFG_SETTING_STATE_EXPERIMENTAL
)
type CfgFlashConflictCode int
@@ -153,6 +154,9 @@ type Cfg struct {
// Use of const settings (error).
Consts map[string]struct{}
+ // Use of experimental settings (warning).
+ Experimental map[string]struct{}
+
// Unresolved value references
UnresolvedValueRefs map[string]struct{}
}
@@ -171,6 +175,7 @@ func NewCfg() Cfg {
Deprecated: map[string]struct{}{},
Defunct: map[string]struct{}{},
Consts: map[string]struct{}{},
+ Experimental: map[string]struct{}{},
UnresolvedValueRefs: map[string]struct{}{},
}
}
@@ -452,6 +457,8 @@ func readSetting(name string, lpkg *pkg.LocalPackage,
entry.State = CFG_SETTING_STATE_DEFUNCT
} else if boolValue(vals["deprecated"]) {
entry.State = CFG_SETTING_STATE_DEPRECATED
+ } else if boolValue(vals["experimental"]) {
+ entry.State = CFG_SETTING_STATE_EXPERIMENTAL
} else {
entry.State = CFG_SETTING_STATE_GOOD
}
@@ -712,6 +719,8 @@ func (cfg *Cfg) readValsOnce(lpkg *pkg.LocalPackage,
cfg.Defunct[k] = struct{}{}
case CFG_SETTING_STATE_CONST:
cfg.Consts[k] = struct{}{}
+ case CFG_SETTING_STATE_EXPERIMENTAL:
+ cfg.Experimental[k] = struct{}{}
}
}
@@ -1120,6 +1129,25 @@ func (cfg *Cfg) DeprecatedWarning() []string {
return lines
}
+func (cfg *Cfg) ExperimentalWarning() []string {
+ lines := []string{}
+
+ for k, _ := range cfg.Experimental {
+ entry, ok := cfg.Settings[k]
+ if !ok {
+ log.Errorf("Internal error; experimental setting \"%s\" not in cfg",
+ k)
+ }
+
+ point := mostRecentPoint(entry)
+ lines = append(lines,
+ fmt.Sprintf("Use of experimental setting %s in %s", k,
+ point.Source.FullName()))
+ }
+
+ return lines
+}
+
func settingName(setting string) string {
return SYSCFG_PREFIX_SETTING + util.CIdentifier(setting)
}
[mynewt-newt] 02/02: Add single state config for syscfg
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit 763d5c03eea359eae9359ce03080466ccc030441
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Mar 22 11:05:18 2022 +0100
Add single state config for syscfg
This can be used intead of separate settings for each state.
---
newt/syscfg/syscfg.go | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index ae30e9e..985cae9 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -463,6 +463,24 @@ func readSetting(name string, lpkg *pkg.LocalPackage,
entry.State = CFG_SETTING_STATE_GOOD
}
+ stateVal, stateExist := vals["state"]
+ if stateExist {
+ if entry.State != CFG_SETTING_STATE_GOOD {
+ util.OneTimeWarning("Setting %s has duplicated state definition, using \"state\".", name)
+ }
+
+ switch stringValue(stateVal) {
+ case "defunct":
+ entry.State = CFG_SETTING_STATE_DEFUNCT
+ case "deprecated":
+ entry.State = CFG_SETTING_STATE_DEPRECATED
+ case "experimental":
+ entry.State = CFG_SETTING_STATE_EXPERIMENTAL
+ default:
+ util.OneTimeWarning("Invalid \"state\" for setting %s, assuming regular state.", name)
+ }
+ }
+
// The value field for setting definition is required.
valueVal, valueExist := vals["value"]
if valueExist {