Repository: incubator-mynewt-newt Updated Branches: refs/heads/develop 23ce34bce -> 04972811d
Warns on unmatched pkg.name and pkg.path Add a warning (in verbose mode, -v) if the pkg.name doesn't match the path. 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/1193eccf Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/1193eccf Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/1193eccf Branch: refs/heads/develop Commit: 1193eccf6c89dec384d0578c19e968f351ff853e Parents: 1fb9697 Author: Fabio Utzig <ut...@utzig.org> Authored: Tue Mar 7 16:48:43 2017 -0300 Committer: Fabio Utzig <ut...@utzig.org> Committed: Tue Mar 7 16:52:51 2017 -0300 ---------------------------------------------------------------------- newt/interfaces/interfaces.go | 1 + newt/pkg/package.go | 2 ++ newt/project/project.go | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1193eccf/newt/interfaces/interfaces.go ---------------------------------------------------------------------- diff --git a/newt/interfaces/interfaces.go b/newt/interfaces/interfaces.go index 6d54f8a..c12b58b 100644 --- a/newt/interfaces/interfaces.go +++ b/newt/interfaces/interfaces.go @@ -22,6 +22,7 @@ package interfaces type PackageInterface interface { Name() string FullName() string + BasePath() string Repo() RepoInterface Type() PackageType } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1193eccf/newt/pkg/package.go ---------------------------------------------------------------------- diff --git a/newt/pkg/package.go b/newt/pkg/package.go index d5d9403..58bf523 100644 --- a/newt/pkg/package.go +++ b/newt/pkg/package.go @@ -71,6 +71,8 @@ type Package interface { FullName() string // The type of package (lib, target, bsp, etc.) Type() interfaces.PackageType + // BasePath is the path on disk if it's a local package + BasePath() string // Hash of the contents of the package Hash() (string, error) // Description of this package http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1193eccf/newt/project/project.go ---------------------------------------------------------------------- diff --git a/newt/project/project.go b/newt/project/project.go index cc68c30..cec5102 100644 --- a/newt/project/project.go +++ b/newt/project/project.go @@ -497,15 +497,42 @@ func (proj *Project) Init(dir string) error { return nil } +func matchNamePath(name, path string) bool { + // assure that name and path use the same path separator... + names := filepath.SplitList(name) + name = filepath.Join(names...) + + if strings.HasSuffix(path, name) { + return true + } + return false +} + func (proj *Project) ResolveDependency(dep interfaces.DependencyInterface) interfaces.PackageInterface { + type NamePath struct { + name string + path string + } + + var errorPkgs []NamePath for _, pkgList := range proj.packages { for _, pkg := range *pkgList { + name := pkg.Name() + path := pkg.BasePath() + if !matchNamePath(name, path) { + errorPkgs = append(errorPkgs, NamePath{name: name, path: path}) + } if dep.SatisfiesDependency(pkg) { return pkg } } } + for _, namepath := range errorPkgs { + util.StatusMessage(util.VERBOSITY_VERBOSE, + "Package name \"%s\" doesn't match path \"%s\"\n", namepath.name, namepath.path) + } + return nil }