You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/09/24 01:43:21 UTC
incubator-mynewt-newt git commit: newt - Allow a lib to override
another's syscfg.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop f4244ec7d -> 4d098d64d
newt - Allow a lib to override another's syscfg.
Prior to this change, library packages could not override settings; only
bsp, unittest, app, and target packages could.
Now, any package can override a setting.
The specific use case which prompted this change:
sys/log defines: LOG_FCB (allow logging to an FCB).
sys/reboot defines: REBOOT_LOG_FCB (log reboots to an FCB).
If the reboot log wants to log to an FCB, LOG_FCB needs to be enabled.
Otherwise, the required functionality will be missing. Enabling
REBOOT_LOG_FCB should override the LOG_FCB setting.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/4d098d64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/4d098d64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/4d098d64
Branch: refs/heads/develop
Commit: 4d098d64d3c4a170b85cb3dd8c26d83b57dfba9b
Parents: f4244ec
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Sep 23 18:36:55 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Sep 23 18:36:55 2016 -0700
----------------------------------------------------------------------
newt/builder/build.go | 7 ++++++-
newt/syscfg/syscfg.go | 28 ++++++++++++++++++----------
2 files changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4d098d64/newt/builder/build.go
----------------------------------------------------------------------
diff --git a/newt/builder/build.go b/newt/builder/build.go
index 5b1106d..6e1596f 100644
--- a/newt/builder/build.go
+++ b/newt/builder/build.go
@@ -119,7 +119,12 @@ func (b *Builder) reloadCfg() (bool, error) {
i++
}
- cfg, err := syscfg.Read(b.sortedLocalPackages(), apis, b.injectedSettings)
+ // Determine which features have been detected so far. The feature map is
+ // required for reloading syscfg, as features may unlock additional
+ // settings.
+ features := syscfg.Features(b.Cfg)
+ cfg, err := syscfg.Read(b.sortedLocalPackages(), apis, b.injectedSettings,
+ features)
if err != nil {
return false, err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/4d098d64/newt/syscfg/syscfg.go
----------------------------------------------------------------------
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index 9550aa8..8efcc8f 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -208,11 +208,15 @@ func readSetting(name string, lpkg *pkg.LocalPackage,
return entry, nil
}
-func readOnce(cfg Cfg, lpkg *pkg.LocalPackage) error {
+func readOnce(cfg Cfg, lpkg *pkg.LocalPackage, features map[string]bool) error {
v := lpkg.Viper
- features := FeaturesForLpkg(cfg, lpkg)
- settings := newtutil.GetStringMapFeatures(v, features, "pkg.syscfg_defs")
+ lfeatures := FeaturesForLpkg(cfg, lpkg)
+ for k, _ := range features {
+ lfeatures[k] = true
+ }
+
+ settings := newtutil.GetStringMapFeatures(v, lfeatures, "pkg.syscfg_defs")
if settings != nil {
for k, v := range settings {
vals := v.(map[interface{}]interface{})
@@ -230,7 +234,7 @@ func readOnce(cfg Cfg, lpkg *pkg.LocalPackage) error {
}
}
- values := newtutil.GetStringMapFeatures(v, features, "pkg.syscfg_vals")
+ values := newtutil.GetStringMapFeatures(v, lfeatures, "pkg.syscfg_vals")
if values != nil {
for k, v := range values {
entry, ok := cfg.Settings[k]
@@ -332,7 +336,7 @@ func apiPresentName(apiName string) string {
}
func Read(lpkgs []*pkg.LocalPackage, apis []string,
- injectedSettings map[string]string) (Cfg, error) {
+ injectedSettings map[string]string, features map[string]bool) (Cfg, error) {
cfg := NewCfg()
for k, v := range injectedSettings {
@@ -345,6 +349,10 @@ func Read(lpkgs []*pkg.LocalPackage, apis []string,
Source: nil,
}},
}
+
+ if ValueIsTrue(v) {
+ features[k] = true
+ }
}
// Read system configuration files. In case of conflicting settings, the
@@ -363,7 +371,7 @@ func Read(lpkgs []*pkg.LocalPackage, apis []string,
for _, lpkg := range lpkgs {
switch lpkg.Type() {
case pkg.PACKAGE_TYPE_LIB:
- if err := readOnce(cfg, lpkg); err != nil {
+ if err := readOnce(cfg, lpkg, features); err != nil {
return cfg, err
}
@@ -382,21 +390,21 @@ func Read(lpkgs []*pkg.LocalPackage, apis []string,
}
if bsp != nil {
- if err := readOnce(cfg, bsp); err != nil {
+ if err := readOnce(cfg, bsp, features); err != nil {
return cfg, err
}
}
if app != nil {
- if err := readOnce(cfg, app); err != nil {
+ if err := readOnce(cfg, app, features); err != nil {
return cfg, err
}
} else if unittest != nil {
- if err := readOnce(cfg, unittest); err != nil {
+ if err := readOnce(cfg, unittest, features); err != nil {
return cfg, err
}
}
if target != nil {
- if err := readOnce(cfg, target); err != nil {
+ if err := readOnce(cfg, target, features); err != nil {
return cfg, err
}
}