You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2017/03/01 04:47:36 UTC
[1/3] incubator-mynewt-newt git commit: newt;
move targetSyscfgKVxxx() routines to be inside syscfg package.
Repository: incubator-mynewt-newt
Updated Branches:
refs/heads/develop 2f4975dc7 -> a404a47c6
newt; move targetSyscfgKVxxx() routines to be inside syscfg package.
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/1a50286f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/1a50286f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/1a50286f
Branch: refs/heads/develop
Commit: 1a50286fabdf32c92d6887be312f35fe30b98682
Parents: 2f4975d
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Feb 28 16:58:21 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Feb 28 16:58:21 2017 -0800
----------------------------------------------------------------------
newt/cli/target_cmds.go | 54 ++------------------------------------------
newt/syscfg/syscfg.go | 50 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1a50286f/newt/cli/target_cmds.go
----------------------------------------------------------------------
diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go
index 8888847..a6ea7df 100644
--- a/newt/cli/target_cmds.go
+++ b/newt/cli/target_cmds.go
@@ -121,7 +121,7 @@ func targetShowCmd(cmd *cobra.Command, args []string) {
}
// A few variables come from the base package rather than the target.
- kvPairs["syscfg"] = targetSyscfgKVToStr(
+ kvPairs["syscfg"] = syscfg.KeyValueToStr(
target.Package().SyscfgV.GetStringMapString("syscfg.vals"))
kvPairs["cflags"] = pkgVarSliceString(target.Package(), "pkg.cflags")
kvPairs["lflags"] = pkgVarSliceString(target.Package(), "pkg.lflags")
@@ -142,56 +142,6 @@ func targetShowCmd(cmd *cobra.Command, args []string) {
}
}
-func targetSyscfgKVFromStr(str string) (map[string]string, error) {
- vals := map[string]string{}
-
- if strings.TrimSpace(str) == "" {
- return vals, nil
- }
-
- // Separate syscfg vals are delimited by ':'.
- fields := strings.Split(str, ":")
-
- // Key-value pairs are delimited by '='. If no '=' is present, assume the
- // string is the key name and the value is 1.
- for _, f := range fields {
- if _, err := util.AtoiNoOct(f); err == nil {
- return nil, util.FmtNewtError(
- "Invalid setting name \"%s\"; must not be a number", f)
- }
-
- kv := strings.SplitN(f, "=", 2)
- switch len(kv) {
- case 1:
- vals[f] = "1"
- case 2:
- vals[kv[0]] = kv[1]
- }
- }
-
- return vals, nil
-}
-
-func targetSyscfgKVToStr(syscfgKv map[string]string) string {
- str := ""
-
- names := make([]string, 0, len(syscfgKv))
- for k, _ := range syscfgKv {
- names = append(names, k)
- }
- sort.Strings(names)
-
- for i, name := range names {
- if i != 0 {
- str += ":"
- }
-
- str += fmt.Sprintf("%s=%s", name, syscfgKv[name])
- }
-
- return str
-}
-
func targetSetCmd(cmd *cobra.Command, args []string) {
if len(args) < 2 {
NewtUsage(cmd,
@@ -234,7 +184,7 @@ func targetSetCmd(cmd *cobra.Command, args []string) {
// instead of the target.
if kv[0] == "target.syscfg" {
t.Package().SyscfgV = viper.New()
- kv, err := targetSyscfgKVFromStr(kv[1])
+ kv, err := syscfg.KeyValueFromStr(kv[1])
if err != nil {
NewtUsage(cmd, err)
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1a50286f/newt/syscfg/syscfg.go
----------------------------------------------------------------------
diff --git a/newt/syscfg/syscfg.go b/newt/syscfg/syscfg.go
index f5cef0e..cac298e 100644
--- a/newt/syscfg/syscfg.go
+++ b/newt/syscfg/syscfg.go
@@ -993,3 +993,53 @@ func EnsureWritten(cfg Cfg, includeDir string) error {
return nil
}
+
+func KeyValueFromStr(str string) (map[string]string, error) {
+ vals := map[string]string{}
+
+ if strings.TrimSpace(str) == "" {
+ return vals, nil
+ }
+
+ // Separate syscfg vals are delimited by ':'.
+ fields := strings.Split(str, ":")
+
+ // Key-value pairs are delimited by '='. If no '=' is present, assume the
+ // string is the key name and the value is 1.
+ for _, f := range fields {
+ if _, err := util.AtoiNoOct(f); err == nil {
+ return nil, util.FmtNewtError(
+ "Invalid setting name \"%s\"; must not be a number", f)
+ }
+
+ kv := strings.SplitN(f, "=", 2)
+ switch len(kv) {
+ case 1:
+ vals[f] = "1"
+ case 2:
+ vals[kv[0]] = kv[1]
+ }
+ }
+
+ return vals, nil
+}
+
+func KeyValueToStr(syscfgKv map[string]string) string {
+ str := ""
+
+ names := make([]string, 0, len(syscfgKv))
+ for k, _ := range syscfgKv {
+ names = append(names, k)
+ }
+ sort.Strings(names)
+
+ for i, name := range names {
+ if i != 0 {
+ str += ":"
+ }
+
+ str += fmt.Sprintf("%s=%s", name, syscfgKv[name])
+ }
+
+ return str
+}
[2/3] incubator-mynewt-newt git commit: newt;
add target.syscfg to build's manifest file.
Posted by st...@apache.org.
newt; add target.syscfg to build's manifest file.
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/2752197f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/2752197f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/2752197f
Branch: refs/heads/develop
Commit: 2752197f7e179df944df58254e8d31154979a8e7
Parents: 1a50286
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Feb 28 16:58:58 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Feb 28 16:58:58 2017 -0800
----------------------------------------------------------------------
newt/builder/targetbuild.go | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/2752197f/newt/builder/targetbuild.go
----------------------------------------------------------------------
diff --git a/newt/builder/targetbuild.go b/newt/builder/targetbuild.go
index f6bc2f6..2576764 100644
--- a/newt/builder/targetbuild.go
+++ b/newt/builder/targetbuild.go
@@ -570,6 +570,13 @@ func (t *TargetBuilder) createManifest() error {
for _, k := range keys {
manifest.TgtVars = append(manifest.TgtVars, k+"="+vars[k])
}
+ syscfgKV := t.GetTarget().Package().SyscfgV.GetStringMapString("syscfg.vals")
+ if len(syscfgKV) > 0 {
+ tgtSyscfg := fmt.Sprintf("target.syscfg=%s",
+ syscfg.KeyValueToStr(syscfgKV))
+ manifest.TgtVars = append(manifest.TgtVars, tgtSyscfg)
+ }
+
file, err := os.Create(t.AppBuilder.ManifestPath())
if err != nil {
return util.FmtNewtError("Cannot create manifest file %s: %s",
[3/3] incubator-mynewt-newt git commit: This closes #43
Posted by st...@apache.org.
This closes #43
Adds target's syscfg variables (if any) to manifest.json.
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/a404a47c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/a404a47c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/a404a47c
Branch: refs/heads/develop
Commit: a404a47c62cd39cc87ba8e306481a921ade8e785
Parents: 2f4975d 2752197
Author: Sterling Hughes <st...@runtime.io>
Authored: Tue Feb 28 20:47:18 2017 -0800
Committer: Sterling Hughes <st...@runtime.io>
Committed: Tue Feb 28 20:47:18 2017 -0800
----------------------------------------------------------------------
newt/builder/targetbuild.go | 7 ++++++
newt/cli/target_cmds.go | 54 ++--------------------------------------
newt/syscfg/syscfg.go | 50 +++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 52 deletions(-)
----------------------------------------------------------------------