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/03/04 20:32:47 UTC
[30/50] [abbrv] incubator-mynewt-newt git commit: (MYNEWT-125)
Include full path for BSP values.
(MYNEWT-125) Include full path for BSP values.
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/e2661138
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/e2661138
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/e2661138
Branch: refs/heads/master
Commit: e2661138d879647a6744436f9ef4efe30d317636
Parents: d4915d4
Author: Christopher Collins <cc...@gmail.com>
Authored: Thu Feb 25 11:54:37 2016 -0800
Committer: Christopher Collins <cc...@gmail.com>
Committed: Thu Feb 25 11:55:28 2016 -0800
----------------------------------------------------------------------
newt/cli/util.go | 15 ++++++++++++---
newt/cli/vars.go | 19 +++++++++++++------
2 files changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2661138/newt/cli/util.go
----------------------------------------------------------------------
diff --git a/newt/cli/util.go b/newt/cli/util.go
index 47549f2..ea2740c 100644
--- a/newt/cli/util.go
+++ b/newt/cli/util.go
@@ -222,7 +222,9 @@ func ChildDirs(path string) ([]string, error) {
return childDirs, nil
}
-func DescendantDirsOfParent(rootPath string, parentName string) ([]string, error) {
+func DescendantDirsOfParent(rootPath string, parentName string, fullPath bool) ([]string, error) {
+ rootPath = path.Clean(rootPath)
+
if NodeNotExist(rootPath) {
return []string{}, nil
}
@@ -234,11 +236,18 @@ func DescendantDirsOfParent(rootPath string, parentName string) ([]string, error
dirs := []string{}
if path.Base(rootPath) == parentName {
- dirs = append(dirs, children...)
+ for _, child := range children {
+ if fullPath {
+ child = rootPath + "/" + child
+ }
+
+ dirs = append(dirs, child)
+ }
} else {
for _, child := range children {
childPath := rootPath + "/" + child
- subDirs, err := DescendantDirsOfParent(childPath, parentName)
+ subDirs, err := DescendantDirsOfParent(childPath, parentName,
+ fullPath)
if err != nil {
return nil, err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/e2661138/newt/cli/vars.go
----------------------------------------------------------------------
diff --git a/newt/cli/vars.go b/newt/cli/vars.go
index d6b682d..eddb8bb 100644
--- a/newt/cli/vars.go
+++ b/newt/cli/vars.go
@@ -22,9 +22,10 @@ package cli
import (
"fmt"
"sort"
+ "strings"
)
-func varsFromChildDirs(key string) ([]string, error) {
+func varsFromChildDirs(key string, fullPath bool) ([]string, error) {
repo, err := NewRepo()
if err != nil {
return nil, err
@@ -34,12 +35,18 @@ func varsFromChildDirs(key string) ([]string, error) {
searchDirs := repo.PkgPaths()
for _, pkgDir := range searchDirs {
pkgBaseDir := repo.BasePath + "/" + pkgDir
- values, err := DescendantDirsOfParent(pkgBaseDir, key)
+ values, err := DescendantDirsOfParent(pkgBaseDir, key, fullPath)
if err != nil {
return nil, NewNewtError(err.Error())
}
+ // Put values into a map to eliminate duplicates.
for _, value := range values {
+ if fullPath {
+ // Don't include the repo base path; we only want the path
+ // relative to the repo.
+ value = strings.TrimPrefix(value, repo.BasePath+"/")
+ }
valueMap[value] = struct{}{}
}
}
@@ -54,19 +61,19 @@ func varsFromChildDirs(key string) ([]string, error) {
var varsMap = map[string]func() ([]string, error){
"arch": func() ([]string, error) {
- return varsFromChildDirs("arch")
+ return varsFromChildDirs("arch", false)
},
"bsp": func() ([]string, error) {
- return varsFromChildDirs("bsp")
+ return varsFromChildDirs("bsp", true)
},
"compiler": func() ([]string, error) {
- return varsFromChildDirs("compiler")
+ return varsFromChildDirs("compiler", false)
},
"project": func() ([]string, error) {
- return varsFromChildDirs("project")
+ return varsFromChildDirs("project", false)
},
}